Skip to content
Permalink
Browse files

Merge pull request #2804 from kssoman/bgp_fix

When redistribute options are changed, call bgp_redistribute_unreg()
  • Loading branch information...
donaldsharp committed Aug 24, 2018
2 parents ff0c9e7 + e923dd6 commit 529089b58e930f7b43637a4cc1f950e62d6ba4ac
Showing with 59 additions and 35 deletions.
  1. +50 −33 bgpd/bgp_vty.c
  2. +7 −1 bgpd/bgp_zebra.c
  3. +2 −1 bgpd/bgp_zebra.h
@@ -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,
@@ -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) {
@@ -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,

0 comments on commit 529089b

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.