]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: adjust redist functionality to current zapi
authorChristian Franke <chris@opensourcerouting.org>
Tue, 20 Jun 2017 20:47:54 +0000 (22:47 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Tue, 20 Jun 2017 20:47:54 +0000 (22:47 +0200)
isisd/isis_redist.c
isisd/isis_zebra.c
isisd/isis_zebra.h

index bdf90aaa1eca31e7fc93cfd6cce8271fb7a5620a..abc4003fe1767f32696bd8f8344239ab762f63e2 100644 (file)
@@ -55,6 +55,18 @@ redist_protocol(int family)
   return 0;
 }
 
+static afi_t
+afi_for_redist_protocol(int protocol)
+{
+  if (protocol == 0)
+    return AFI_IP;
+  if (protocol == 1)
+    return AFI_IP6;
+
+  assert(!"Unknown redist protocol!");
+  return AFI_IP;
+}
+
 static int
 is_default(struct prefix *p)
 {
@@ -387,7 +399,7 @@ isis_redist_update_zebra_subscriptions(struct isis *isis)
   int level;
   int protocol;
 
-  char do_subscribe[ZEBRA_ROUTE_MAX + 1];
+  char do_subscribe[REDIST_PROTOCOL_COUNT][ZEBRA_ROUTE_MAX + 1];
 
   memset(do_subscribe, 0, sizeof(do_subscribe));
 
@@ -396,20 +408,23 @@ isis_redist_update_zebra_subscriptions(struct isis *isis)
       for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
         for (level = 0; level < ISIS_LEVELS; level++)
           if (area->redist_settings[protocol][type][level].redist)
-            do_subscribe[type] = 1;
+            do_subscribe[protocol][type] = 1;
 
-  for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
-    {
-      /* This field is actually controlling transmission of the IS-IS
-       * routes to Zebra and has nothing to do with redistribution,
-       * so skip it. */
-      if (type == ZEBRA_ROUTE_ISIS)
-        continue;
+  for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++)
+    for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
+      {
+        /* This field is actually controlling transmission of the IS-IS
+         * routes to Zebra and has nothing to do with redistribution,
+         * so skip it. */
+        if (type == ZEBRA_ROUTE_ISIS)
+          continue;
 
-      if (do_subscribe[type])
-        isis_zebra_redistribute_set(type);
-      else
-        isis_zebra_redistribute_unset(type);
+        afi_t afi = afi_for_redist_protocol(protocol);
+
+        if (do_subscribe[protocol][type])
+          isis_zebra_redistribute_set(afi, type);
+        else
+          isis_zebra_redistribute_unset(afi, type);
     }
 }
 
index e7bd99c3e84d073f669805c6055671b398fed948..79bc752e5f5aa4510c06d3140b30ee0990b44ce2 100644 (file)
@@ -602,6 +602,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
   struct stream *stream;
   struct zapi_ipv6 api;
   struct prefix_ipv6 p;
+  struct prefix src_p;
   struct prefix *p_generic = (struct prefix*)&p;
   struct in6_addr nexthop;
   unsigned long ifindex __attribute__((unused));
@@ -613,6 +614,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
   ifindex = 0;
 
   api.type = stream_getc(stream);
+  api.instance = stream_getw(stream);
   api.flags = stream_getl(stream);
   api.message = stream_getc(stream);
 
@@ -620,6 +622,18 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
   p.prefixlen = stream_getc(stream);
   stream_get(&p.prefix, stream, PSIZE(p.prefixlen));
 
+  memset(&src_p, 0, sizeof (struct prefix));
+  src_p.family = AF_INET6;
+  if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
+    {
+      src_p.prefixlen = stream_getc(stream);
+      stream_get(&src_p.u.prefix6, stream, PSIZE (src_p.prefixlen));
+    }
+
+  if (src_p.prefixlen)
+    /* we completely ignore srcdest routes for now. */
+    return 0;
+
   if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP))
     {
       api.nexthop_num = stream_getc(stream); /* this is always 1 */
@@ -634,6 +648,8 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
     api.distance = stream_getc(stream);
   if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC))
     api.metric = stream_getl(stream);
+  if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
+    api.tag = stream_getl(stream);
 
   /*
    * Avoid advertising a false default reachability. (A default
@@ -644,7 +660,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient,
   if (p.prefixlen == 0 && api.type == ZEBRA_ROUTE_ISIS)
     command = ZEBRA_IPV6_ROUTE_DELETE;
 
-  if (command == ZEBRA_IPV6_ROUTE_ADD)
+  if (command == ZEBRA_REDISTRIBUTE_IPV6_ADD)
     isis_redist_add(api.type, p_generic, api.distance, api.metric);
   else
     isis_redist_delete(api.type, p_generic);
@@ -659,21 +675,21 @@ isis_distribute_list_update (int routetype)
 }
 
 void
-isis_zebra_redistribute_set(int type)
+isis_zebra_redistribute_set(afi_t afi, int type)
 {
   if (type == DEFAULT_ROUTE)
     zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, VRF_DEFAULT);
   else
-    zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
+    zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT);
 }
 
 void
-isis_zebra_redistribute_unset(int type)
+isis_zebra_redistribute_unset(afi_t afi, int type)
 {
   if (type == DEFAULT_ROUTE)
     zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, VRF_DEFAULT);
   else
-    zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
+    zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT);
 }
 
 static void
index 217e3d48cdbe5dbdd2ef3a9987eb7f3765cd9ca0..69759a627c76ee5f9a69475c1bb09f19052e1234 100644 (file)
@@ -28,7 +28,7 @@ void isis_zebra_init(struct thread_master *);
 void isis_zebra_route_update (struct prefix *prefix,
                              struct isis_route_info *route_info);
 int isis_distribute_list_update (int routetype);
-void isis_zebra_redistribute_set(int type);
-void isis_zebra_redistribute_unset(int type);
+void isis_zebra_redistribute_set(afi_t afi, int type);
+void isis_zebra_redistribute_unset(afi_t afi, int type);
 
 #endif /* _ZEBRA_ISIS_ZEBRA_H */