]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: do not ignore ipv6 srcdest routes 2707/head
authorChristian Franke <chris@opensourcerouting.org>
Mon, 23 Jul 2018 01:40:42 +0000 (03:40 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Tue, 24 Jul 2018 12:09:17 +0000 (14:09 +0200)
Commit a2ca67d1d2 consolidated IPv4 and IPv6 handling. It also applied
our ignorance for IPv4 srcdest routes onto IPv6.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra/rt_netlink.c
zebra/zebra_rib.c

index b346247d4b5a3de297f0a804bcfb26976f46b092..572577b0c5742155d7d9e2feae4302c8251dd07b 100644 (file)
@@ -387,8 +387,15 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                memcpy(&p.u.prefix4, dest, 4);
                p.prefixlen = rtm->rtm_dst_len;
 
-               src_p.prefixlen =
-                       0; // Forces debug below to not display anything
+               if (rtm->rtm_src_len != 0) {
+                       char buf[PREFIX_STRLEN];
+                       zlog_warn("unsupported IPv4 sourcedest route (dest %s vrf %u)",
+                                 prefix2str(&p, buf, sizeof(buf)), vrf_id);
+                       return 0;
+               }
+
+               /* Force debug below to not display anything for source */
+               src_p.prefixlen = 0;
        } else if (rtm->rtm_family == AF_INET6) {
                p.family = AF_INET6;
                memcpy(&p.u.prefix6, dest, 16);
@@ -399,14 +406,6 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                src_p.prefixlen = rtm->rtm_src_len;
        }
 
-       if (rtm->rtm_src_len != 0) {
-               char buf[PREFIX_STRLEN];
-               zlog_warn(
-                       "unsupported IPv[4|6] sourcedest route (dest %s vrf %u)",
-                       prefix2str(&p, buf, sizeof(buf)), vrf_id);
-               return 0;
-       }
-
        /*
         * For ZEBRA_ROUTE_KERNEL types:
         *
@@ -492,7 +491,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                        nh.vrf_id = nh_vrf_id;
 
                        rib_add(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, &p,
-                               NULL, &nh, table, metric, mtu, distance, tag);
+                               &src_p, &nh, table, metric, mtu, distance, tag);
                } else {
                        /* This is a multipath route */
 
@@ -591,8 +590,8 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                        if (re->nexthop_num == 0)
                                XFREE(MTYPE_RE, re);
                        else
-                               rib_add_multipath(afi, SAFI_UNICAST, &p, NULL,
-                                                 re);
+                               rib_add_multipath(afi, SAFI_UNICAST, &p,
+                                                 &src_p, re);
                }
        } else {
                if (!tb[RTA_MULTIPATH]) {
@@ -624,12 +623,12 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
                        if (gate)
                                memcpy(&nh.gate, gate, sz);
                        rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags,
-                                  &p, NULL, &nh, table, metric, true);
+                                  &p, &src_p, &nh, table, metric, true);
                } else {
                        /* XXX: need to compare the entire list of nexthops
                         * here for NLM_F_APPEND stupidity */
                        rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags,
-                                  &p, NULL, NULL, table, metric, true);
+                                  &p, &src_p, NULL, table, metric, true);
                }
        }
 
index 9bf6bfa22f08d949d19879a43408b744315e49f4..71d48632c14a434ec50c4f5abe61a8f42b7f40ec 100644 (file)
@@ -2331,7 +2331,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
        if (!re)
                return 0;
 
-       assert(!src_p || afi == AFI_IP6);
+       assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
 
        /* Lookup table.  */
        table = zebra_vrf_table_with_table_id(afi, safi, re->vrf_id, re->table);
@@ -2421,7 +2421,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
        char buf2[INET6_ADDRSTRLEN];
        rib_dest_t *dest;
 
-       assert(!src_p || afi == AFI_IP6);
+       assert(!src_p || !src_p->prefixlen || afi == AFI_IP6);
 
        /* Lookup table.  */
        table = zebra_vrf_table_with_table_id(afi, safi, vrf_id, table_id);