summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-08-24 07:46:22 -0400
committerGitHub <noreply@github.com>2018-08-24 07:46:22 -0400
commit529089b58e930f7b43637a4cc1f950e62d6ba4ac (patch)
treece73a5fac1ca6c924e39d4346a74efc69804bb82
parentff0c9e7a0abf46750b40a41464ecd7aabea0e97c (diff)
parente923dd62ef715147a3e0d28a8e9dccb9371defcb (diff)
Merge pull request #2804 from kssoman/bgp_fix
When redistribute options are changed, call bgp_redistribute_unreg()
-rw-r--r--bgpd/bgp_vty.c83
-rw-r--r--bgpd/bgp_zebra.c8
-rw-r--r--bgpd/bgp_zebra.h3
3 files changed, 59 insertions, 35 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 98d9ffcceb..62f337a876 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -11548,7 +11548,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(
@@ -11569,6 +11569,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) {
@@ -11577,8 +11578,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(
@@ -11602,6 +11603,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) {
@@ -11611,8 +11613,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(
@@ -11639,6 +11641,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) {
@@ -11648,9 +11651,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(
@@ -11681,6 +11684,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) {
@@ -11690,9 +11694,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(
@@ -11728,7 +11732,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,
@@ -11755,6 +11759,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;
@@ -11763,8 +11768,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,
@@ -11795,6 +11800,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;
@@ -11805,8 +11811,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,
@@ -11840,6 +11847,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;
@@ -11850,9 +11858,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(
@@ -11889,6 +11898,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;
@@ -11899,9 +11909,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(
@@ -12009,7 +12020,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,
@@ -12025,6 +12036,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) {
@@ -12033,8 +12045,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,
@@ -12051,6 +12063,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) {
@@ -12060,8 +12073,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,
@@ -12081,6 +12094,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) {
@@ -12090,9 +12104,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,
@@ -12112,6 +12127,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) {
@@ -12121,9 +12137,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,
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 3434717484..f42c16c1c1 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1576,8 +1576,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) {
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index e3c88b9db6..546d72402a 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -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,