]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Store commonly used values instead of regenerating
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 26 May 2017 01:11:24 +0000 (21:11 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 26 May 2017 01:11:24 +0000 (21:11 -0400)
the ipv4_ll address used for 5549 routes does not need
to be figured out every single time that we attempt
to install/remove a route of that type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/kernel_netlink.c
zebra/rt_netlink.c
zebra/rt_netlink.h

index 3efad44acb385ca5674a39ec8d526811bb72f82d..e23801169bbc0535648cfa7254c5cdba422ab05c 100644 (file)
@@ -817,6 +817,8 @@ kernel_init (struct zebra_ns *zns)
       thread_add_read(zebrad.master, kernel_read, zns, zns->netlink.sock,
                       &zns->t_netlink);
     }
+
+  rt_netlink_init ();
 }
 
 void
index 3c4f3171ffd9a46e62d707e992b6c061bf8c048a..4f1131809a2d67f6cbbdc3db00a1ca3322525e26 100644 (file)
@@ -102,6 +102,21 @@ struct gw_family_t
   union g_addr  gate;
 };
 
+char ipv4_ll_buf[16] = "169.254.0.1";
+struct in_addr ipv4_ll;
+
+/*
+ * The ipv4_ll data structure is used for all 5549
+ * additions to the kernel.  Let's figure out the
+ * correct value one time instead for every
+ * install/remove of a 5549 type route
+ */
+void
+rt_netlink_init (void)
+{
+  inet_pton (AF_INET, ipv4_ll_buf, &ipv4_ll);
+}
+
 static inline int is_selfroute(int proto)
 {
   if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF) ||
@@ -678,10 +693,6 @@ _netlink_route_build_singlepath(
       (nexthop->type == NEXTHOP_TYPE_IPV6
       || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
     {
-      char buf[16] = "169.254.0.1";
-      struct in_addr ipv4_ll;
-
-      inet_pton (AF_INET, buf, &ipv4_ll);
       rtmsg->rtm_flags |= RTNH_F_ONLINK;
       addattr_l (nlmsg, req_size, RTA_GATEWAY, &ipv4_ll, 4);
       addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
@@ -696,7 +707,7 @@ _netlink_route_build_singlepath(
       if (IS_ZEBRA_DEBUG_KERNEL)
         zlog_debug(" 5549: _netlink_route_build_singlepath() (%s): "
                    "nexthop via %s if %u",
-                   routedesc, buf, nexthop->ifindex);
+                   routedesc, ipv4_ll_buf, nexthop->ifindex);
       return;
     }
 
@@ -883,10 +894,6 @@ _netlink_route_build_multipath(
       (nexthop->type == NEXTHOP_TYPE_IPV6
       || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX))
     {
-      char buf[16] = "169.254.0.1";
-      struct in_addr ipv4_ll;
-
-      inet_pton (AF_INET, buf, &ipv4_ll);
       bytelen = 4;
       rtnh->rtnh_flags |= RTNH_F_ONLINK;
       rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTA_GATEWAY,
@@ -902,7 +909,7 @@ _netlink_route_build_multipath(
       if (IS_ZEBRA_DEBUG_KERNEL)
         zlog_debug(" 5549: netlink_route_build_multipath() (%s): "
                    "nexthop via %s if %u",
-                   routedesc, buf, nexthop->ifindex);
+                   routedesc, ipv4_ll_buf, nexthop->ifindex);
       return;
     }
 
index 0e305beb37ad7e06d319087384caec23175d4500..4ec5f18535cb15a12fe561753324cc00b0c43af3 100644 (file)
@@ -34,6 +34,7 @@
 #define RTPROT_RIP         189
 #define RTPROT_RIPNG       190
 
+void rt_netlink_init (void);
 
 extern void
 clear_nhlfe_installed (zebra_lsp_t *lsp);