
equinox at diac24
Jul 25, 2012, 9:20 AM
Post #2 of 2
(151 views)
Permalink
|
|
Re: [PATCH 2/5] babeld: code simplification for redistribution.
[In reply to]
|
|
Matthieu, this patch doesn't apply on master, most likely because it's missing stuff from -RE. There is no automatic propagation of stuff from -RE to master; anything that shall go into master needs to show up on this mailing list, either as patch or as git pull request. The babeld patches are interspersed on -RE with other patches, which makes pulling them in somewhat difficult for me. I can automate it with some magic, i.e. list out all changes affecting babeld/, but it'd still be nice if patches that are supposed to go into master show up on the ML. The preferred way for babeld changes to get merged would be if you had a public git repo that I can do a git pull/git merge from. Cheers, David [.At some point, going through RE and picking stuff needs to happen anyway, yes. But merging things that show up here on the ML has higher priority, and I'm doing a mediocre job at that as-is, so merging -RE is something I can't afford the time for right now. Contributions welcome.] On Fri, Jul 20, 2012 at 06:30:23PM +0200, Matthieu Boutier wrote: > From: Matthieu Boutier <boutier [at] pps> > > Use loops and variables instead of doing each cases by hand. > Replace BABEL_FILTER* macros by DISTRIBUTE* enumeration. > --- > babeld/babel_filter.c | 47 ++++++++++++++++++++++++---------------------- > babeld/babel_interface.h | 8 +++----- > babeld/babeld.c | 49 +++++++++++------------------------------------- > 3 files changed, 39 insertions(+), 65 deletions(-) > > diff --git a/babeld/babel_filter.c b/babeld/babel_filter.c > index f7ecdcf..6e97e0e 100644 > --- a/babeld/babel_filter.c > +++ b/babeld/babel_filter.c > @@ -38,7 +38,6 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, > struct distribute *dist; > struct access_list *alist; > struct prefix_list *plist; > - int filter = output ? BABEL_FILTER_OUT : BABEL_FILTER_IN; > int distribute = output ? DISTRIBUTE_OUT : DISTRIBUTE_IN; > > p.family = v4mapped(prefix) ? AF_INET : AF_INET6; > @@ -48,26 +47,28 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, > else > uchar_to_in6addr(&p.u.prefix6, prefix); > > - if (babel_ifp != NULL && babel_ifp->list[filter]) { > - if (access_list_apply (babel_ifp->list[filter], &p) > + if (babel_ifp != NULL && babel_ifp->list[distribute]) { > + if (access_list_apply (babel_ifp->list[distribute], &p) > == FILTER_DENY) { > debugf(BABEL_DEBUG_FILTER, > - "%s/%d filtered by distribute in", > + "%s/%d filtered by distribute %s", > p.family == AF_INET ? > inet_ntoa(p.u.prefix4) : > inet6_ntoa (p.u.prefix6), > - p.prefixlen); > + p.prefixlen, > + output ? "out" : "in"); > return INFINITY; > } > } > - if (babel_ifp != NULL && babel_ifp->prefix[filter]) { > - if (prefix_list_apply (babel_ifp->prefix[filter], &p) > + if (babel_ifp != NULL && babel_ifp->prefix[distribute]) { > + if (prefix_list_apply (babel_ifp->prefix[distribute], &p) > == PREFIX_DENY) { > - debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute in", > - p.family == AF_INET ? > - inet_ntoa(p.u.prefix4) : > - inet6_ntoa (p.u.prefix6), > - p.prefixlen); > + debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute %s", > + p.family == AF_INET ? > + inet_ntoa(p.u.prefix4) : > + inet6_ntoa (p.u.prefix6), > + p.prefixlen, > + output ? "out" : "in"); > return INFINITY; > } > } > @@ -80,11 +81,12 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, > > if (alist) { > if (access_list_apply (alist, &p) == FILTER_DENY) { > - debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute in", > - p.family == AF_INET ? > - inet_ntoa(p.u.prefix4) : > - inet6_ntoa (p.u.prefix6), > - p.prefixlen); > + debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s", > + p.family == AF_INET ? > + inet_ntoa(p.u.prefix4) : > + inet6_ntoa (p.u.prefix6), > + p.prefixlen, > + output ? "out" : "in"); > return INFINITY; > } > } > @@ -93,11 +95,12 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, > plist = prefix_list_lookup (AFI_IP6, dist->prefix[distribute]); > if (plist) { > if (prefix_list_apply (plist, &p) == PREFIX_DENY) { > - debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute in", > - p.family == AF_INET ? > - inet_ntoa(p.u.prefix4) : > - inet6_ntoa (p.u.prefix6), > - p.prefixlen); > + debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s", > + p.family == AF_INET ? > + inet_ntoa(p.u.prefix4) : > + inet6_ntoa (p.u.prefix6), > + p.prefixlen, > + output ? "out" : "in"); > return INFINITY; > } > } > diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h > index 5053ecd..fe086be 100644 > --- a/babeld/babel_interface.h > +++ b/babeld/babel_interface.h > @@ -26,6 +26,7 @@ THE SOFTWARE. > #include <zebra.h> > #include "zclient.h" > #include "vty.h" > +#include "distribute.h" > > #define CONFIG_DEFAULT 0 > #define CONFIG_NO 1 > @@ -62,11 +63,8 @@ struct babel_interface { > unsigned update_interval; > > /* For filter type slot. */ > -#define BABEL_FILTER_IN 0 > -#define BABEL_FILTER_OUT 1 > -#define BABEL_FILTER_MAX 2 > - struct access_list *list[BABEL_FILTER_MAX]; /* Access-list. */ > - struct prefix_list *prefix[BABEL_FILTER_MAX]; /* Prefix-list. */ > + struct access_list *list[DISTRIBUTE_MAX]; /* Access-list. */ > + struct prefix_list *prefix[DISTRIBUTE_MAX]; /* Prefix-list. */ > struct list *csalist; /* list of CSAs */ > }; > > diff --git a/babeld/babeld.c b/babeld/babeld.c > index 763bfb1..e99800e 100644 > --- a/babeld/babeld.c > +++ b/babeld/babeld.c > @@ -536,8 +536,8 @@ babel_distribute_update (struct distribute *dist) > { > struct interface *ifp; > babel_interface_nfo *babel_ifp; > - struct access_list *alist; > - struct prefix_list *plist; > + int type; > + int family = AFI_IP6; > > if (! dist->ifname) > return; > @@ -548,44 +548,17 @@ babel_distribute_update (struct distribute *dist) > > babel_ifp = babel_get_if_nfo(ifp); > > - if (dist->list[DISTRIBUTE_IN]) { > - alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_IN]); > - if (alist) > - babel_ifp->list[BABEL_FILTER_IN] = alist; > + for (type = 0; type < DISTRIBUTE_MAX; type++) { > + if (dist->list[type]) > + babel_ifp->list[type] = access_list_lookup (family, > + dist->list[type]); > else > - babel_ifp->list[BABEL_FILTER_IN] = NULL; > - } else { > - babel_ifp->list[BABEL_FILTER_IN] = NULL; > - } > - > - if (dist->list[DISTRIBUTE_OUT]) { > - alist = access_list_lookup (AFI_IP6, dist->list[DISTRIBUTE_OUT]); > - if (alist) > - babel_ifp->list[BABEL_FILTER_OUT] = alist; > - else > - babel_ifp->list[BABEL_FILTER_OUT] = NULL; > - } else { > - babel_ifp->list[BABEL_FILTER_OUT] = NULL; > - } > - > - if (dist->prefix[DISTRIBUTE_IN]) { > - plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_IN]); > - if (plist) > - babel_ifp->prefix[BABEL_FILTER_IN] = plist; > - else > - babel_ifp->prefix[BABEL_FILTER_IN] = NULL; > - } else { > - babel_ifp->prefix[BABEL_FILTER_IN] = NULL; > - } > - > - if (dist->prefix[DISTRIBUTE_OUT]) { > - plist = prefix_list_lookup (AFI_IP6, dist->prefix[DISTRIBUTE_OUT]); > - if (plist) > - babel_ifp->prefix[BABEL_FILTER_OUT] = plist; > + babel_ifp->list[type] = NULL; > + if (dist->prefix[type]) > + babel_ifp->prefix[type] = prefix_list_lookup (family, > + dist->prefix[type]); > else > - babel_ifp->prefix[BABEL_FILTER_OUT] = NULL; > - } else { > - babel_ifp->prefix[BABEL_FILTER_OUT] = NULL; > + babel_ifp->prefix[type] = NULL; > } > } > > -- > 1.7.11.1 > > _______________________________________________ > Quagga-dev mailing list > Quagga-dev [at] lists > http://lists.quagga.net/mailman/listinfo/quagga-dev
|