diff options
| author | Russ White <russ@riw.us> | 2023-04-04 08:20:25 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 08:20:25 -0400 | 
| commit | c0656e90406bcac5094a8bce86c03c1913a80831 (patch) | |
| tree | c7f3e393f0ba2deab99c721fd2b452710a74f485 /babeld | |
| parent | 6fc9bfb11ddf5c187bad91e1a759361d249f512f (diff) | |
| parent | 71cb4a57a8a2047623497d2e4100b5c99d236b81 (diff) | |
Merge pull request #12837 from donaldsharp/unlikely_routemap
Unlikely routemap
Diffstat (limited to 'babeld')
| -rw-r--r-- | babeld/babeld.c | 62 | ||||
| -rw-r--r-- | babeld/babeld.h | 4 | ||||
| -rw-r--r-- | babeld/util.h | 9 | 
3 files changed, 37 insertions, 38 deletions
diff --git a/babeld/babeld.c b/babeld/babeld.c index 4ce92c5204..f4c932971e 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -444,37 +444,39 @@ 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)) {printIfMin(a,b,c,d);} - -    struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); -    struct interface *ifp = NULL; +#define printIfMin(a, b, c, d)                                                 \ +	if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) {                           \ +		printIfMin(a, b, c, d);                                        \ +	} -    *tv = check_neighbours_timeout; -    printIfMin(tv, 0, "check_neighbours_timeout", NULL); -    timeval_min_sec(tv, expiry_time); -    printIfMin(tv, 1, "expiry_time", NULL); -    timeval_min_sec(tv, source_expiry_time); -    printIfMin(tv, 1, "source_expiry_time", NULL); -    timeval_min(tv, &resend_time); -    printIfMin(tv, 1, "resend_time", NULL); -    FOR_ALL_INTERFACES(vrf, ifp) { -        babel_interface_nfo *babel_ifp = NULL; -        if(!if_up(ifp)) -            continue; -        babel_ifp = babel_get_if_nfo(ifp); -        timeval_min(tv, &babel_ifp->flush_timeout); -        printIfMin(tv, 1, "flush_timeout", ifp->name); -        timeval_min(tv, &babel_ifp->hello_timeout); -        printIfMin(tv, 1, "hello_timeout", ifp->name); -        timeval_min(tv, &babel_ifp->update_timeout); -        printIfMin(tv, 1, "update_timeout", ifp->name); -        timeval_min(tv, &babel_ifp->update_flush_timeout); -        printIfMin(tv, 1, "update_flush_timeout",ifp->name); -    } -    timeval_min(tv, &unicast_flush_timeout); -    printIfMin(tv, 1, "unicast_flush_timeout", NULL); -    printIfMin(tv, 2, NULL, NULL); +	struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); +	struct interface *ifp = NULL; + +	*tv = check_neighbours_timeout; +	printIfMin(tv, 0, "check_neighbours_timeout", NULL); +	timeval_min_sec(tv, expiry_time); +	printIfMin(tv, 1, "expiry_time", NULL); +	timeval_min_sec(tv, source_expiry_time); +	printIfMin(tv, 1, "source_expiry_time", NULL); +	timeval_min(tv, &resend_time); +	printIfMin(tv, 1, "resend_time", NULL); +	FOR_ALL_INTERFACES (vrf, ifp) { +		babel_interface_nfo *babel_ifp = NULL; +		if (!if_up(ifp)) +			continue; +		babel_ifp = babel_get_if_nfo(ifp); +		timeval_min(tv, &babel_ifp->flush_timeout); +		printIfMin(tv, 1, "flush_timeout", ifp->name); +		timeval_min(tv, &babel_ifp->hello_timeout); +		printIfMin(tv, 1, "hello_timeout", ifp->name); +		timeval_min(tv, &babel_ifp->update_timeout); +		printIfMin(tv, 1, "update_timeout", ifp->name); +		timeval_min(tv, &babel_ifp->update_flush_timeout); +		printIfMin(tv, 1, "update_flush_timeout", ifp->name); +	} +	timeval_min(tv, &unicast_flush_timeout); +	printIfMin(tv, 1, "unicast_flush_timeout", NULL); +	printIfMin(tv, 2, NULL, NULL);  #undef printIfMin  #endif  } diff --git a/babeld/babeld.h b/babeld/babeld.h index 6c51af48a8..619550f651 100644 --- a/babeld/babeld.h +++ b/babeld/babeld.h @@ -26,12 +26,8 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek  #if defined(__GNUC__) && (__GNUC__ >= 3)  #define ATTRIBUTE(x) __attribute__ (x) -#define LIKELY(_x) __builtin_expect(!!(_x), 1) -#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)  #else  #define ATTRIBUTE(x) /**/ -#define LIKELY(_x) !!(_x) -#define UNLIKELY(_x) !!(_x)  #endif  #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) diff --git a/babeld/util.h b/babeld/util.h index 5e5843543a..8535d4dd6a 100644 --- a/babeld/util.h +++ b/babeld/util.h @@ -122,10 +122,11 @@ extern const unsigned char v4prefix[16];  #define BABEL_DEBUG_ROUTE       (1 << 5)  #define BABEL_DEBUG_ALL         (0xFFFF) -#define debugf(level, ...) \ -do { \ -if(UNLIKELY(debug & level)) zlog_debug(__VA_ARGS__);     \ -} while(0) +#define debugf(level, ...)                                                     \ +	do {                                                                   \ +		if (unlikely(debug & level))                                   \ +			zlog_debug(__VA_ARGS__);                               \ +	} while (0)  #endif /* NO_DEBUG */  | 
