diff options
Diffstat (limited to 'babeld')
-rw-r--r-- | babeld/kernel_zebra.c | 84 |
1 files changed, 26 insertions, 58 deletions
diff --git a/babeld/kernel_zebra.c b/babeld/kernel_zebra.c index 97b7c584..f23403ec 100644 --- a/babeld/kernel_zebra.c +++ b/babeld/kernel_zebra.c @@ -59,26 +59,20 @@ THE SOFTWARE. static int kernel_route_add_v4(const unsigned char *pref, unsigned short plen, - const unsigned char *gate, int ifindex, unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric); + const unsigned char *gate, int ifindex, + unsigned int metric); static int kernel_route_add_v6(const unsigned char *pref, unsigned short plen, - const unsigned char *gate, int ifindex, unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric); + const unsigned char *gate, int ifindex, + unsigned int metric); static int kernel_route_delete_v4(const unsigned char *pref, unsigned short plen, const unsigned char *gate, int ifindex, - unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric); + unsigned int metric); static int kernel_route_delete_v6(const unsigned char *pref, unsigned short plen, const unsigned char *gate, int ifindex, - unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric); + unsigned int metric); int kernel_interface_operational(struct interface *interface) @@ -125,47 +119,29 @@ kernel_route(int operation, const unsigned char *pref, unsigned short plen, switch (operation) { case ROUTE_ADD: return ipv4 ? - kernel_route_add_v4(pref, plen, gate, ifindex, metric, - newgate, newifindex, newmetric): - kernel_route_add_v6(pref, plen, gate, ifindex, metric, - newgate, newifindex, newmetric); + kernel_route_add_v4(pref, plen, gate, ifindex, metric): + kernel_route_add_v6(pref, plen, gate, ifindex, metric); break; case ROUTE_FLUSH: return ipv4 ? - kernel_route_delete_v4(pref, plen, gate, ifindex, metric, - newgate, newifindex, newmetric): - kernel_route_delete_v6(pref, plen, gate, ifindex, metric, - newgate, newifindex, newmetric); + kernel_route_delete_v4(pref, plen, gate, ifindex, metric): + kernel_route_delete_v6(pref, plen, gate, ifindex, metric); break; case ROUTE_MODIFY: if(newmetric == metric && memcmp(newgate, gate, 16) == 0 && newifindex == ifindex) return 0; debugf(BABEL_DEBUG_ROUTE, "Modify route: delete old; add new."); - if (ipv4) { - kernel_route_delete_v4(pref, plen, - gate, ifindex, metric, - NULL, 0, 0); - } else { - kernel_route_delete_v6(pref, plen, - gate, ifindex, metric, - NULL, 0, 0); - } + rc = ipv4 ? + kernel_route_delete_v4(pref, plen, gate, ifindex, metric): + kernel_route_delete_v6(pref, plen, gate, ifindex, metric); + + if (rc < 0) + return -1; rc = ipv4 ? - kernel_route_add_v4(pref, plen, - newgate, newifindex, newmetric, - NULL, 0, 0): - kernel_route_add_v6(pref, plen, - newgate, newifindex, newmetric, - NULL, 0, 0); - if(rc < 0) { - if(errno == EEXIST) - rc = 1; - /* In principle, we should try to re-install the flushed - route on failure to preserve. However, this should - hopefully not matter much in practice. */ - } + kernel_route_add_v4(pref, plen, newgate, newifindex, newmetric): + kernel_route_add_v6(pref, plen, newgate, newifindex, newmetric); return rc; break; @@ -179,9 +155,7 @@ kernel_route(int operation, const unsigned char *pref, unsigned short plen, static int kernel_route_add_v4(const unsigned char *pref, unsigned short plen, - const unsigned char *gate, int ifindex, unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric) + const unsigned char *gate, int ifindex, unsigned int metric) { unsigned int tmp_ifindex = ifindex; /* (for typing) */ struct zapi_ipv4 api; /* quagga's communication system */ @@ -190,7 +164,7 @@ kernel_route_add_v4(const unsigned char *pref, unsigned short plen, struct in_addr nexthop; /* next router to go */ struct in_addr *nexthop_pointer = &nexthop; /* it's an array! */ - /* convert to be comprehensive by quagga */ + /* convert to be understandable by quagga */ /* convert given addresses */ uchar_to_inaddr(&babel_prefix_addr, pref); uchar_to_inaddr(&nexthop, gate); @@ -222,9 +196,7 @@ kernel_route_add_v4(const unsigned char *pref, unsigned short plen, static int kernel_route_add_v6(const unsigned char *pref, unsigned short plen, - const unsigned char *gate, int ifindex, unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric) + const unsigned char *gate, int ifindex, unsigned int metric) { unsigned int tmp_ifindex = ifindex; /* (for typing) */ struct zapi_ipv6 api; /* quagga's communication system */ @@ -233,7 +205,7 @@ kernel_route_add_v6(const unsigned char *pref, unsigned short plen, struct in6_addr nexthop; /* next router to go */ struct in6_addr *nexthop_pointer = &nexthop; - /* convert to be comprehensive by quagga */ + /* convert to be understandable by quagga */ /* convert given addresses */ uchar_to_in6addr(&babel_prefix_addr, pref); uchar_to_in6addr(&nexthop, gate); @@ -266,9 +238,7 @@ kernel_route_add_v6(const unsigned char *pref, unsigned short plen, static int kernel_route_delete_v4(const unsigned char *pref, unsigned short plen, const unsigned char *gate, int ifindex, - unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric) + unsigned int metric) { unsigned int tmp_ifindex = ifindex; /* (for typing) */ struct zapi_ipv4 api; /* quagga's communication system */ @@ -277,7 +247,7 @@ kernel_route_delete_v4(const unsigned char *pref, unsigned short plen, struct in_addr nexthop; /* next router to go */ struct in_addr *nexthop_pointer = &nexthop; /* it's an array! */ - /* convert to be comprehensive by quagga */ + /* convert to be understandable by quagga */ /* convert given addresses */ uchar_to_inaddr(&babel_prefix_addr, pref); uchar_to_inaddr(&nexthop, gate); @@ -310,9 +280,7 @@ kernel_route_delete_v4(const unsigned char *pref, unsigned short plen, static int kernel_route_delete_v6(const unsigned char *pref, unsigned short plen, const unsigned char *gate, int ifindex, - unsigned int metric, - const unsigned char *newgate, int newifindex, - unsigned int newmetric) + unsigned int metric) { unsigned int tmp_ifindex = ifindex; /* (for typing) */ struct zapi_ipv6 api; /* quagga's communication system */ @@ -321,7 +289,7 @@ kernel_route_delete_v6(const unsigned char *pref, unsigned short plen, struct in6_addr nexthop; /* next router to go */ struct in6_addr *nexthop_pointer = &nexthop; - /* convert to be comprehensive by quagga */ + /* convert to be understandable by quagga */ /* convert given addresses */ uchar_to_in6addr(&babel_prefix_addr, pref); uchar_to_in6addr(&nexthop, gate); |