Skip to content

Commit 026d278

Browse files
committed
babeld: Convert all code to use our code formatting rules
The babeld code was originally kept in a non-standard format, at least to how FRR formats code, because the code came from outside the project and it was hoped that updates would be coming from the originators. That has not turned out to be true and we've been slowly getting bug-fixes for the code over the last year as it is being used. Let's just bite the bullet and convert over to our internal format for consistency. Signed-off-by: Donald Sharp <[email protected]>
1 parent f283943 commit 026d278

28 files changed

Lines changed: 5698 additions & 6161 deletions

babeld/babel_filter.c

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,76 +15,71 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
1515
#include "distribute.h"
1616
#include "util.h"
1717

18-
int
19-
babel_filter(int output, const unsigned char *prefix, unsigned short plen,
20-
unsigned int ifindex)
18+
int babel_filter(int output, const unsigned char *prefix, unsigned short plen, unsigned int ifindex)
2119
{
22-
struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
23-
babel_interface_nfo *babel_ifp = ifp ? babel_get_if_nfo(ifp) : NULL;
24-
struct prefix p;
25-
struct distribute *dist = NULL;
26-
struct access_list *alist;
27-
struct prefix_list *plist;
28-
int distribute;
29-
struct babel *babel;
30-
afi_t family;
20+
struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
21+
babel_interface_nfo *babel_ifp = ifp ? babel_get_if_nfo(ifp) : NULL;
22+
struct prefix p;
23+
struct distribute *dist = NULL;
24+
struct access_list *alist;
25+
struct prefix_list *plist;
26+
int distribute;
27+
struct babel *babel;
28+
afi_t family;
3129

32-
p.family = v4mapped(prefix) ? AF_INET : AF_INET6;
33-
p.prefixlen = v4mapped(prefix) ? plen - 96 : plen;
34-
if (p.family == AF_INET) {
35-
uchar_to_inaddr(&p.u.prefix4, prefix);
36-
distribute = output ? DISTRIBUTE_V4_OUT : DISTRIBUTE_V4_IN;
37-
family = AFI_IP;
38-
} else {
39-
uchar_to_in6addr(&p.u.prefix6, prefix);
40-
distribute = output ? DISTRIBUTE_V6_OUT : DISTRIBUTE_V6_IN;
41-
family = AFI_IP6;
42-
}
30+
p.family = v4mapped(prefix) ? AF_INET : AF_INET6;
31+
p.prefixlen = v4mapped(prefix) ? plen - 96 : plen;
32+
if (p.family == AF_INET) {
33+
uchar_to_inaddr(&p.u.prefix4, prefix);
34+
distribute = output ? DISTRIBUTE_V4_OUT : DISTRIBUTE_V4_IN;
35+
family = AFI_IP;
36+
} else {
37+
uchar_to_in6addr(&p.u.prefix6, prefix);
38+
distribute = output ? DISTRIBUTE_V6_OUT : DISTRIBUTE_V6_IN;
39+
family = AFI_IP6;
40+
}
4341

44-
if (babel_ifp != NULL && babel_ifp->list[distribute]) {
45-
if (access_list_apply (babel_ifp->list[distribute], &p)
46-
== FILTER_DENY) {
47-
debugf(BABEL_DEBUG_FILTER,
48-
"%pFX filtered by distribute %s",
49-
&p, output ? "out" : "in");
50-
return INFINITY;
42+
if (babel_ifp != NULL && babel_ifp->list[distribute]) {
43+
if (access_list_apply(babel_ifp->list[distribute], &p) == FILTER_DENY) {
44+
debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s", &p,
45+
output ? "out" : "in");
46+
return INFINITY;
47+
}
5148
}
52-
}
53-
if (babel_ifp != NULL && babel_ifp->prefix[distribute]) {
54-
if (prefix_list_apply (babel_ifp->prefix[distribute], &p)
55-
== PREFIX_DENY) {
56-
debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s",
57-
&p, output ? "out" : "in");
58-
return INFINITY;
49+
if (babel_ifp != NULL && babel_ifp->prefix[distribute]) {
50+
if (prefix_list_apply(babel_ifp->prefix[distribute], &p) == PREFIX_DENY) {
51+
debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s", &p,
52+
output ? "out" : "in");
53+
return INFINITY;
54+
}
5955
}
60-
}
6156

62-
/* All interface filter check. */
63-
babel = babel_lookup();
64-
if (babel)
65-
dist = distribute_lookup (babel->distribute_ctx, NULL);
66-
if (dist) {
67-
if (dist->list[distribute]) {
68-
alist = access_list_lookup (family, dist->list[distribute]);
57+
/* All interface filter check. */
58+
babel = babel_lookup();
59+
if (babel)
60+
dist = distribute_lookup(babel->distribute_ctx, NULL);
61+
if (dist) {
62+
if (dist->list[distribute]) {
63+
alist = access_list_lookup(family, dist->list[distribute]);
6964

70-
if (alist) {
71-
if (access_list_apply (alist, &p) == FILTER_DENY) {
72-
debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s",
73-
&p, output ? "out" : "in");
74-
return INFINITY;
65+
if (alist) {
66+
if (access_list_apply(alist, &p) == FILTER_DENY) {
67+
debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s",
68+
&p, output ? "out" : "in");
69+
return INFINITY;
70+
}
71+
}
7572
}
76-
}
77-
}
78-
if (dist->prefix[distribute]) {
79-
plist = prefix_list_lookup (family, dist->prefix[distribute]);
80-
if (plist) {
81-
if (prefix_list_apply (plist, &p) == PREFIX_DENY) {
82-
debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s",
83-
&p, output ? "out" : "in");
84-
return INFINITY;
73+
if (dist->prefix[distribute]) {
74+
plist = prefix_list_lookup(family, dist->prefix[distribute]);
75+
if (plist) {
76+
if (prefix_list_apply(plist, &p) == PREFIX_DENY) {
77+
debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s",
78+
&p, output ? "out" : "in");
79+
return INFINITY;
80+
}
81+
}
8582
}
86-
}
8783
}
88-
}
89-
return 0;
84+
return 0;
9085
}

babeld/babel_filter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
1010
#include "prefix.h"
1111
#include "babel_interface.h"
1212

13-
int babel_filter(int output, const unsigned char *prefix, unsigned short plen,
14-
unsigned int index);
13+
int babel_filter(int output, const unsigned char *prefix, unsigned short plen, unsigned int index);
1514

1615
#endif /* BABELD_BABEL_FILTER_H */

0 commit comments

Comments
 (0)