]> git.puffer.fish Git - mirror/frr.git/commitdiff
pbrd: adjust/remove the rule correctly when dst and/or src removed 1903/head
authorDon Slice <dslice@cumulusnetworks.com>
Mon, 26 Mar 2018 19:16:09 +0000 (19:16 +0000)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 6 Apr 2018 17:22:43 +0000 (13:22 -0400)
When the last match criteria was removed (dst-ip or src-ip), we were
not deleting the rule correctly for ipv6. This fix retains the
needed src-ip/dst-ip during the pbr_send_pbr_map process so the
appropriate information is available for the rule delete.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
pbrd/pbr_map.c
pbrd/pbr_map.h
pbrd/pbr_vty.c
pbrd/pbr_zebra.c
zebra/rule_netlink.c

index 5962509e822824497afbf3b7ebc76a80e3158816..ea79320a712501a12bbd9adc61d3667b383366f6 100644 (file)
@@ -527,13 +527,6 @@ void pbr_map_check(struct pbr_map_sequence *pbrms)
               __PRETTY_FUNCTION__, pbrm->name, pbrms->seqno, pbrms->reason);
 
        if (pbrms->reason == PBR_MAP_VALID_SEQUENCE_NUMBER) {
-               if (pbrms->installed) {
-                       install = false;
-                       for (ALL_LIST_ELEMENTS_RO(pbrm->incoming, inode, pmi)) {
-                               pbr_send_pbr_map(pbrms, pmi, install);
-                       }
-                       install = true;
-               }
                install = true;
                DEBUGD(&pbr_dbg_map, "%s: Installing %s(%u) reason: %" PRIu64,
                       __PRETTY_FUNCTION__, pbrm->name, pbrms->seqno,
index 12d49d98c0ee9a77648ed1089b1d845c0c5d868d..5cb22d7429ebb3a4acf2198e441d98dc09f243bb 100644 (file)
@@ -85,6 +85,11 @@ struct pbr_map_sequence {
        struct prefix *src;
        struct prefix *dst;
 
+       /*
+        * Family of the src/dst.  Needed when deleting since we clear them
+        */
+       unsigned char family;
+
        /*
         * The nexthop group we auto create
         * for when the user specifies a individual
index a4f3c54646412e62952c9d6d636b894a04700018..87ec3804a53778164475fc6ed100f29a0aed7317 100644 (file)
@@ -95,6 +95,8 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
 {
        struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
 
+       pbrms->family = prefix->family;
+
        if (!no) {
                if (prefix_same(pbrms->src, prefix))
                        return CMD_SUCCESS;
@@ -122,6 +124,8 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
 {
        struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
 
+       pbrms->family = prefix->family;
+
        if (!no) {
                if (prefix_same(pbrms->dst, prefix))
                        return CMD_SUCCESS;
index 971fe65aafac16b95a8f685b2459929138204db9..a1a2d34ac1d8499d64e2f4604fdce407b44979fa 100644 (file)
@@ -455,7 +455,7 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)
 
 static void pbr_encode_pbr_map_sequence_prefix(struct stream *s,
                                               struct prefix *p,
-                                              u_char family)
+                                              unsigned char  family)
 {
        struct prefix any;
 
@@ -474,14 +474,11 @@ static void pbr_encode_pbr_map_sequence(struct stream *s,
                                        struct pbr_map_sequence *pbrms,
                                        struct interface *ifp)
 {
-       u_char family;
+       unsigned char family;
 
        family = AF_INET;
-       if (pbrms->src)
-               family = pbrms->src->family;
-
-       if (pbrms->dst)
-               family = pbrms->dst->family;
+       if (pbrms->family)
+               family = pbrms->family;
 
        stream_putl(s, pbrms->seqno);
        stream_putl(s, pbrms->ruleno);
index 2122f9f5fa12f308bab4b219eec1252f2b32b74a..dc942204a4ba39b4e3e6be823613828a1705a7ca 100644 (file)
@@ -77,9 +77,6 @@ static int netlink_rule_update(int cmd, struct zebra_pbr_rule *rule)
        req.frh.family = family;
        req.frh.action = FR_ACT_TO_TBL;
 
-       if (cmd == RTM_NEWRULE)
-               req.n.nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
-
        /* rule's pref # */
        addattr32(&req.n, sizeof(req), FRA_PRIORITY, rule->priority);