]> git.proxmox.com Git - mirror_frr.git/blobdiff - babeld/kernel.c
Merge pull request #12795 from pguibert6WIND/vpnv6_nexthop_encoding
[mirror_frr.git] / babeld / kernel.c
index d4c962af3b4390d38ce78ab57e1f742defe09003..f89fe268df370d362fbab054fda02eddc544666f 100644 (file)
@@ -1,24 +1,7 @@
+// SPDX-License-Identifier: MIT
 /*
 Copyright 2007, 2008 by GrĂ©goire Henry, Julien Cristau and Juliusz Chroboczek
 Copyright 2011, 2012 by Matthieu Boutier and Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
 */
 
 #ifdef HAVE_CONFIG_H
@@ -103,10 +86,8 @@ kernel_route(enum babel_kernel_routes operation, const unsigned char *pref,
     switch (operation) {
         case ROUTE_ADD:
             return zebra_route(1, family, pref, plen, gate, ifindex, metric);
-            break;
         case ROUTE_FLUSH:
             return zebra_route(0, family, pref, plen, gate, ifindex, metric);
-            break;
         case ROUTE_MODIFY:
             if(newmetric == metric && memcmp(newgate, gate, 16) == 0 &&
                newifindex == ifindex)
@@ -119,7 +100,6 @@ kernel_route(enum babel_kernel_routes operation, const unsigned char *pref,
             rc = zebra_route(1, family, pref, plen, newgate, newifindex,
                              newmetric);
             return rc;
-            break;
     }
 
     return 0;
@@ -179,11 +159,11 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen,
        switch (family) {
         case AF_INET:
             uchar_to_inaddr(&api_nh->gate.ipv4, gate);
-            if (IPV4_ADDR_SAME (&api_nh->gate.ipv4, &quagga_prefix.u.prefix4) &&
-                    quagga_prefix.prefixlen == 32) {
-                api_nh->type = NEXTHOP_TYPE_IFINDEX;
-            } else {
-                api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+           if (IPV4_ADDR_SAME(&api_nh->gate.ipv4, &quagga_prefix.u.prefix4)
+               && quagga_prefix.prefixlen == IPV4_MAX_BITLEN) {
+                   api_nh->type = NEXTHOP_TYPE_IFINDEX;
+           } else {
+                   api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX;
             }
             break;
         case AF_INET6:
@@ -230,10 +210,10 @@ if_eui64(int ifindex, unsigned char *eui)
 
 /* Like gettimeofday, but returns monotonic time.  If POSIX clocks are not
    available, falls back to gettimeofday but enforces monotonicity. */
-int
+void
 gettime(struct timeval *tv)
 {
-    return monotime(tv);
+    monotime(tv);
 }
 
 /* If /dev/urandom doesn't exist, this will fail with ENOENT, which the