mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 00:56:19 +00:00
Fix redistribute metric change not taking effect
Ticket: CM-6048 Reviewed-By: CCR-3251 Tested: See bug When a redistribute metric is changed, the new metric was not being used. Modify the code to look for existing redistributed routes and fix their metric.
This commit is contained in:
parent
b07c4cb33e
commit
caf958b43a
@ -10972,7 +10972,7 @@ DEFUN (bgp_redistribute_ipv4_metric,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[1]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, type, 0);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
|
||||
return bgp_redistribute_set (AFI_IP, type, 0);
|
||||
}
|
||||
|
||||
@ -11000,7 +11000,7 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, type, 0);
|
||||
bgp_redistribute_rmap_set (red, argv[1]);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
|
||||
return bgp_redistribute_set (AFI_IP, type, 0);
|
||||
}
|
||||
|
||||
@ -11027,7 +11027,7 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[1]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, type, 0);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
|
||||
bgp_redistribute_rmap_set (red, argv[2]);
|
||||
return bgp_redistribute_set (AFI_IP, type, 0);
|
||||
}
|
||||
@ -11103,7 +11103,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[2]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
|
||||
return bgp_redistribute_set (AFI_IP, protocol, instance);
|
||||
}
|
||||
|
||||
@ -11134,7 +11134,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
|
||||
bgp_redistribute_rmap_set (red, argv[2]);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
|
||||
return bgp_redistribute_set (AFI_IP, protocol, instance);
|
||||
}
|
||||
|
||||
@ -11164,7 +11164,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[2]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
|
||||
bgp_redistribute_rmap_set (red, argv[3]);
|
||||
return bgp_redistribute_set (AFI_IP, protocol, instance);
|
||||
}
|
||||
@ -11360,7 +11360,7 @@ DEFUN (bgp_redistribute_ipv6_metric,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[1]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
|
||||
return bgp_redistribute_set (AFI_IP6, type, 0);
|
||||
}
|
||||
|
||||
@ -11388,7 +11388,7 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
|
||||
bgp_redistribute_rmap_set (red, argv[1]);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
|
||||
return bgp_redistribute_set (AFI_IP6, type, 0);
|
||||
}
|
||||
|
||||
@ -11415,7 +11415,7 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
|
||||
VTY_GET_INTEGER ("metric", metric, argv[1]);
|
||||
|
||||
red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
|
||||
bgp_redistribute_metric_set (red, metric);
|
||||
bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
|
||||
bgp_redistribute_rmap_set (red, argv[2]);
|
||||
return bgp_redistribute_set (AFI_IP6, type, 0);
|
||||
}
|
||||
|
@ -1602,8 +1602,12 @@ bgp_redistribute_rmap_set (struct bgp_redist *red, const char *name)
|
||||
|
||||
/* Redistribute with metric specification. */
|
||||
int
|
||||
bgp_redistribute_metric_set (struct bgp_redist *red, u_int32_t metric)
|
||||
bgp_redistribute_metric_set (struct bgp *bgp, struct bgp_redist *red, afi_t afi,
|
||||
int type, u_int32_t metric)
|
||||
{
|
||||
struct bgp_node *rn;
|
||||
struct bgp_info *ri;
|
||||
|
||||
if (red->redist_metric_flag
|
||||
&& red->redist_metric == metric)
|
||||
return 0;
|
||||
@ -1611,6 +1615,16 @@ bgp_redistribute_metric_set (struct bgp_redist *red, u_int32_t metric)
|
||||
red->redist_metric_flag = 1;
|
||||
red->redist_metric = metric;
|
||||
|
||||
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; rn = bgp_route_next(rn)) {
|
||||
for (ri = rn->info; ri; ri = ri->next) {
|
||||
if (ri->sub_type == BGP_ROUTE_REDISTRIBUTE && ri->type == type) {
|
||||
ri->attr->med = red->redist_metric;
|
||||
bgp_info_set_flag(rn, ri, BGP_INFO_ATTR_CHANGED);
|
||||
bgp_process(bgp, rn, afi, SAFI_UNICAST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,8 @@ extern struct bgp_redist *bgp_redist_add (struct bgp *, afi_t, u_char, u_short);
|
||||
extern int bgp_redistribute_set (afi_t, int, u_short);
|
||||
extern int bgp_redistribute_resend (struct bgp *, afi_t, int, u_short);
|
||||
extern int bgp_redistribute_rmap_set (struct bgp_redist *, const char *);
|
||||
extern int bgp_redistribute_metric_set (struct bgp_redist *, u_int32_t);
|
||||
extern int bgp_redistribute_metric_set(struct bgp *, struct bgp_redist *,
|
||||
afi_t, int, u_int32_t);
|
||||
extern int bgp_redistribute_unset (struct bgp *, afi_t, int, u_short);
|
||||
|
||||
extern struct interface *if_lookup_by_ipv4 (struct in_addr *);
|
||||
|
Loading…
Reference in New Issue
Block a user