]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd : Change of options in redistribute command does not get applied
authorkssoman <somanks@vmware.com>
Wed, 22 Aug 2018 12:00:15 +0000 (05:00 -0700)
committerkssoman <somanks@vmware.com>
Wed, 22 Aug 2018 12:00:15 +0000 (05:00 -0700)
* Added parameter in bgp_redistribute_set() to indicate change
  in redistribute option
* If there is change, call bgp_redistribute_unreg() to withdraw routes

Signed-off-by: kssoman <somanks@vmware.com>
bgpd/bgp_vty.c
bgpd/bgp_zebra.c
bgpd/bgp_zebra.h

index e3efbbf252ea9e7a68ddda5f35afdfdcd48d4c60..69e3de3b2a2eb123f1bcea8d515f17b2147a644f 100644 (file)
@@ -11460,7 +11460,7 @@ DEFUN (bgp_redistribute_ipv4,
        }
 
        bgp_redist_add(bgp, AFI_IP, type, 0);
-       return bgp_redistribute_set(bgp, AFI_IP, type, 0);
+       return bgp_redistribute_set(bgp, AFI_IP, type, 0, false);
 }
 
 ALIAS_HIDDEN(
@@ -11481,6 +11481,7 @@ DEFUN (bgp_redistribute_ipv4_rmap,
        int idx_word = 3;
        int type;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11489,8 +11490,8 @@ DEFUN (bgp_redistribute_ipv4_rmap,
        }
 
        red = bgp_redist_add(bgp, AFI_IP, type, 0);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP, type, 0);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11514,6 +11515,7 @@ DEFUN (bgp_redistribute_ipv4_metric,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11523,8 +11525,8 @@ DEFUN (bgp_redistribute_ipv4_metric,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, type, 0);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
-       return bgp_redistribute_set(bgp, AFI_IP, type, 0);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
+       return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11551,6 +11553,7 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11560,9 +11563,9 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, type, 0);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
-       return bgp_redistribute_set(bgp, AFI_IP, type, 0);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
+       return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11593,6 +11596,7 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11602,9 +11606,9 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, type, 0);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP, type, 0);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
+       changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11640,7 +11644,7 @@ DEFUN (bgp_redistribute_ipv4_ospf,
                protocol = ZEBRA_ROUTE_TABLE;
 
        bgp_redist_add(bgp, AFI_IP, protocol, instance);
-       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance);
+       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false);
 }
 
 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd,
@@ -11667,6 +11671,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
        struct bgp_redist *red;
        unsigned short instance;
        int protocol;
+       bool changed;
 
        if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
                protocol = ZEBRA_ROUTE_OSPF;
@@ -11675,8 +11680,8 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap,
 
        instance = strtoul(argv[idx_number]->arg, NULL, 10);
        red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed);
 }
 
 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap,
@@ -11707,6 +11712,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
        struct bgp_redist *red;
        unsigned short instance;
        int protocol;
+       bool changed;
 
        if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
                protocol = ZEBRA_ROUTE_OSPF;
@@ -11717,8 +11723,9 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
        metric = strtoul(argv[idx_number_2]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
-       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol,
+                                               metric);
+       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed);
 }
 
 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric,
@@ -11752,6 +11759,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
        struct bgp_redist *red;
        unsigned short instance;
        int protocol;
+       bool changed;
 
        if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
                protocol = ZEBRA_ROUTE_OSPF;
@@ -11762,9 +11770,10 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
        metric = strtoul(argv[idx_number_2]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
-       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol,
+                                               metric);
+       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11801,6 +11810,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
        struct bgp_redist *red;
        unsigned short instance;
        int protocol;
+       bool changed;
 
        if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
                protocol = ZEBRA_ROUTE_OSPF;
@@ -11811,9 +11821,10 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
        metric = strtoul(argv[idx_number_2]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol,
+                                               metric);
+       changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed);
 }
 
 ALIAS_HIDDEN(
@@ -11921,7 +11932,7 @@ DEFUN (bgp_redistribute_ipv6,
        }
 
        bgp_redist_add(bgp, AFI_IP6, type, 0);
-       return bgp_redistribute_set(bgp, AFI_IP6, type, 0);
+       return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false);
 }
 
 DEFUN (bgp_redistribute_ipv6_rmap,
@@ -11937,6 +11948,7 @@ DEFUN (bgp_redistribute_ipv6_rmap,
        int idx_word = 3;
        int type;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11945,8 +11957,8 @@ DEFUN (bgp_redistribute_ipv6_rmap,
        }
 
        red = bgp_redist_add(bgp, AFI_IP6, type, 0);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP6, type, 0);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed);
 }
 
 DEFUN (bgp_redistribute_ipv6_metric,
@@ -11963,6 +11975,7 @@ DEFUN (bgp_redistribute_ipv6_metric,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
        if (type < 0) {
@@ -11972,8 +11985,8 @@ DEFUN (bgp_redistribute_ipv6_metric,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP6, type, 0);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
-       return bgp_redistribute_set(bgp, AFI_IP6, type, 0);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
+       return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed);
 }
 
 DEFUN (bgp_redistribute_ipv6_rmap_metric,
@@ -11993,6 +12006,7 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
        if (type < 0) {
@@ -12002,9 +12016,10 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP6, type, 0);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
-       return bgp_redistribute_set(bgp, AFI_IP6, type, 0);
+       changed = bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type,
+                                               metric);
+       return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed);
 }
 
 DEFUN (bgp_redistribute_ipv6_metric_rmap,
@@ -12024,6 +12039,7 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
        int type;
        uint32_t metric;
        struct bgp_redist *red;
+       bool changed;
 
        type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
        if (type < 0) {
@@ -12033,9 +12049,10 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
        metric = strtoul(argv[idx_number]->arg, NULL, 10);
 
        red = bgp_redist_add(bgp, AFI_IP6, type, 0);
-       bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric);
-       bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
-       return bgp_redistribute_set(bgp, AFI_IP6, type, 0);
+       changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST,
+                                               metric);
+       changed |= bgp_redistribute_rmap_set(red, argv[idx_word]->arg);
+       return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed);
 }
 
 DEFUN (no_bgp_redistribute_ipv6,
index 9591fe673f74d89f8a6a82781b4abf1de455ac83..7bd0b1bfa38f0ebd7a7bb74eec1861c86e84e5af 100644 (file)
@@ -1574,8 +1574,14 @@ static void bgp_redist_del(struct bgp *bgp, afi_t afi, uint8_t type,
 
 /* Other routes redistribution into BGP. */
 int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
-                        unsigned short instance)
+                        unsigned short instance, bool changed)
 {
+       /* If redistribute options are changed call
+        * bgp_redistribute_unreg() to reset the option and withdraw
+        * the routes
+        */
+       if (changed)
+               bgp_redistribute_unreg(bgp, afi, type, instance);
 
        /* Return if already redistribute flag is set. */
        if (instance) {
index e3c88b9db664712e4eab521a4faef8da42214cef..546d72402af819ef288f9a4a0914cfae50e56cb7 100644 (file)
@@ -51,7 +51,8 @@ extern struct bgp_redist *bgp_redist_lookup(struct bgp *, afi_t, uint8_t,
                                            unsigned short);
 extern struct bgp_redist *bgp_redist_add(struct bgp *, afi_t, uint8_t,
                                         unsigned short);
-extern int bgp_redistribute_set(struct bgp *, afi_t, int, unsigned short);
+extern int bgp_redistribute_set(struct bgp *, afi_t, int, unsigned short,
+                               bool changed);
 extern int bgp_redistribute_resend(struct bgp *, afi_t, int, unsigned short);
 extern int bgp_redistribute_rmap_set(struct bgp_redist *, const char *);
 extern int bgp_redistribute_metric_set(struct bgp *, struct bgp_redist *, afi_t,