Skip to content

Commit

Permalink
Merge branch 'FRRouting:master' into fix-reload-interface-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jklaiber authored Jan 13, 2025
2 parents 0513050 + a962ff7 commit 2312529
Show file tree
Hide file tree
Showing 1,057 changed files with 52,382 additions and 13,403 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
ColumnLimit: 100
# Linux: CommentPragmas: '^ IWYU pragma:'
CommentPragmas: '\$(FRR|clippy)'
CompactNamespaces: false
Expand Down
9 changes: 8 additions & 1 deletion babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ babel_interface_close_all(void)
{
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
int type;

FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
Expand All @@ -740,8 +741,14 @@ babel_interface_close_all(void)
flushbuf(ifp);
usleep(roughly(10000));
gettime(&babel_now);
babel_enable_if_delete(ifp->name);
interface_reset(ifp);
}
/* Disable babel redistribution */
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
}
}

/* return "true" if address is one of our ipv6 addresses */
Expand Down Expand Up @@ -1351,7 +1358,7 @@ babel_interface_allocate (void)
/* All flags are unset */
babel_ifp->bucket_time = babel_now.tv_sec;
babel_ifp->bucket = BUCKET_TOKENS_MAX;
babel_ifp->hello_seqno = (frr_weak_random() & 0xFFFF);
babel_ifp->hello_seqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_ifp->rtt_decay = BABEL_DEFAULT_RTT_DECAY;
babel_ifp->rtt_min = BABEL_DEFAULT_RTT_MIN;
babel_ifp->rtt_max = BABEL_DEFAULT_RTT_MAX;
Expand Down
12 changes: 9 additions & 3 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static void babel_read_protocol(struct event *thread)
making these inits have sense. */
static void babel_init_routing_process(struct event *thread)
{
myseqno = (frr_weak_random() & 0xFFFF);
myseqno = CHECK_FLAG(frr_weak_random(), 0xFFFF);
babel_get_myid();
babel_load_state_file();
debugf(BABEL_DEBUG_COMMON, "My ID is : %s.", format_eui64(myid));
Expand Down Expand Up @@ -304,6 +304,12 @@ void babel_clean_routing_process(void)
flush_all_routes();
babel_interface_close_all();

/* Clean babel config */
diversity_kind = DIVERSITY_NONE;
diversity_factor = BABEL_DEFAULT_DIVERSITY_FACTOR;
resend_delay = BABEL_DEFAULT_RESEND_DELAY;
change_smoothing_half_life(BABEL_DEFAULT_SMOOTHING_HALF_LIFE);

/* cancel events */
event_cancel(&babel_routing_process->t_read);
event_cancel(&babel_routing_process->t_update);
Expand Down Expand Up @@ -443,8 +449,8 @@ babel_fill_with_next_timeout(struct timeval *tv)
#if (defined NO_DEBUG)
#define printIfMin(a,b,c,d)
#else
#define printIfMin(a, b, c, d) \
if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) { \
#define printIfMin(a, b, c, d) \
if (unlikely(CHECK_FLAG(debug, BABEL_DEBUG_TIMEOUT))) { \
printIfMin(a, b, c, d); \
}

Expand Down
16 changes: 8 additions & 8 deletions babeld/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ parse_request_subtlv(int ae, const unsigned char *a, int alen,
have_src_prefix = 1;
} else {
debugf(BABEL_DEBUG_COMMON,"Received unknown%s Route Request sub-TLV %d.",
((type & 0x80) != 0) ? " mandatory" : "", type);
if((type & 0x80) != 0)
(CHECK_FLAG(type, 0x80) != 0) ? " mandatory" : "", type);
if(CHECK_FLAG(type, 0x80) != 0)
return -1;
}

Expand Down Expand Up @@ -588,15 +588,15 @@ parse_packet(const unsigned char *from, struct interface *ifp,
else
rc = -1;
if(rc < 0) {
if(message[3] & 0x80)
if(CHECK_FLAG(message[3], 0x80))
have_v4_prefix = have_v6_prefix = 0;
goto fail;
}
parsed_len = 10 + rc;

plen = message[4] + (message[2] == 1 ? 96 : 0);

if(message[3] & 0x80) {
if(CHECK_FLAG(message[3], 0x80)) {
if(message[2] == 1) {
memcpy(v4_prefix, prefix, 16);
have_v4_prefix = 1;
Expand All @@ -605,7 +605,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
have_v6_prefix = 1;
}
}
if(message[3] & 0x40) {
if(CHECK_FLAG(message[3], 0x40)) {
if(message[2] == 1) {
memset(router_id, 0, 4);
memcpy(router_id + 4, prefix + 12, 4);
Expand All @@ -620,8 +620,8 @@ parse_packet(const unsigned char *from, struct interface *ifp,
goto fail;
}
debugf(BABEL_DEBUG_COMMON,"Received update%s%s for %s from %s on %s.",
(message[3] & 0x80) ? "/prefix" : "",
(message[3] & 0x40) ? "/id" : "",
((CHECK_FLAG(message[3], 0x80)) ? "/prefix" : ""),
((CHECK_FLAG(message[3], 0x40)) ? "/id" : ""),
format_prefix(prefix, plen),
format_address(from), ifp->name);

Expand Down Expand Up @@ -1059,7 +1059,7 @@ void send_hello_noupdate(struct interface *ifp, unsigned interval)
babel_ifp->hello_seqno, interval, ifp->name);

start_message(ifp, MESSAGE_HELLO,
(babel_ifp->flags & BABEL_IF_TIMESTAMPS) ? 12 : 6);
(CHECK_FLAG(babel_ifp->flags, BABEL_IF_TIMESTAMPS) ? 12 : 6));
babel_ifp->buffered_hello = babel_ifp->buffered - 2;
accumulate_short(ifp, 0);
accumulate_short(ifp, babel_ifp->hello_seqno);
Expand Down
9 changes: 5 additions & 4 deletions babeld/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ mask_prefix(unsigned char *restrict ret,
memset(ret, 0, 16);
memcpy(ret, prefix, plen / 8);
if(plen % 8 != 0)
ret[plen / 8] =
(prefix[plen / 8] & ((0xFF << (8 - (plen % 8))) & 0xFF));
ret[plen / 8] = CHECK_FLAG(prefix[plen / 8],
CHECK_FLAG((0xFF << (8 - (plen % 8))), 0xFF));
return ret;
}

Expand Down Expand Up @@ -353,12 +353,13 @@ martian_prefix(const unsigned char *prefix, int plen)
{
return
(plen >= 8 && prefix[0] == 0xFF) ||
(plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
(plen >= 10 && prefix[0] == 0xFE &&
(CHECK_FLAG(prefix[1], 0xC0) == 0x80)) ||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
(prefix[15] == 0 || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
(plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
(plen >= 100 && CHECK_FLAG(prefix[12], 0xE0) == 0xE0)));
}

int
Expand Down
8 changes: 4 additions & 4 deletions babeld/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ seqno_compare(unsigned short s1, unsigned short s2)
if(s1 == s2)
return 0;
else
return ((s2 - s1) & 0x8000) ? 1 : -1;
return (CHECK_FLAG((s2 - s1), 0x8000)) ? 1 : -1;
}

static inline short
seqno_minus(unsigned short s1, unsigned short s2)
{
return (short)((s1 - s2) & 0xFFFF);
return (short)(CHECK_FLAG((s1 - s2), 0xFFFF));
}

static inline unsigned short
seqno_plus(unsigned short s, int plus)
{
return ((s + plus) & 0xFFFF);
return CHECK_FLAG((s + plus), 0xFFFF);
}

/* Returns a time in microseconds on 32 bits (thus modulo 2^32,
Expand Down Expand Up @@ -130,7 +130,7 @@ is_default(const unsigned char *prefix, int plen)

#define debugf(level, ...) \
do { \
if (unlikely(debug & level)) \
if (unlikely(CHECK_FLAG(debug, level))) \
zlog_debug(__VA_ARGS__); \
} while (0)

Expand Down
Loading

0 comments on commit 2312529

Please sign in to comment.