mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 02:46:26 +00:00
zebra: Allow one connected route per network mask on a interface
Currently FRR reads the kernel for interface state and FRR creates a connected route per address on an interface. If you are in a situation where you have multiple addresses on an interface just create 1 connected route for them: sharpd@eva:/tmp/topotests$ vtysh -c "show int dummy302" Interface dummy302 is up, line protocol is up Link ups: 0 last: (never) Link downs: 0 last: (never) vrf: default index 3279 metric 0 mtu 1500 speed 0 flags: <UP,BROADCAST,RUNNING,NOARP> Type: Ethernet HWaddr: aa:4a:ed:95:9f:18 inet 10.4.1.1/24 inet 10.4.1.2/24 secondary inet 10.4.1.3/24 secondary inet 10.4.1.4/24 secondary inet 10.4.1.5/24 secondary inet6 fe80::a84a:edff:fe95:9f18/64 Interface Type Other Interface Slave Type None protodown: off sharpd@eva:/tmp/topotests$ vtysh -c "show ip route connected" Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure C>* 10.4.1.0/24 is directly connected, dummy302, 00:10:03 C>* 192.168.161.0/24 is directly connected, enp39s0, 00:10:03 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
adf1bb9f0c
commit
9298056138
@ -208,6 +208,9 @@ void connected_up(struct interface *ifp, struct connected *ifc)
|
||||
struct zebra_vrf *zvrf;
|
||||
uint32_t metric;
|
||||
uint32_t flags = 0;
|
||||
uint32_t count = 0;
|
||||
struct listnode *cnode;
|
||||
struct connected *c;
|
||||
|
||||
zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
|
||||
if (!zvrf) {
|
||||
@ -263,6 +266,27 @@ void connected_up(struct interface *ifp, struct connected *ifc)
|
||||
if (zrouter.asic_offloaded)
|
||||
flags |= ZEBRA_FLAG_OFFLOADED;
|
||||
|
||||
/*
|
||||
* It's possible to add the same network and mask
|
||||
* to an interface over and over. This would
|
||||
* result in an equivalent number of connected
|
||||
* routes. Just add one connected route in
|
||||
* for all the addresses on an interface that
|
||||
* resolve to the same network and mask
|
||||
*/
|
||||
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
||||
struct prefix cp;
|
||||
|
||||
PREFIX_COPY(&cp, CONNECTED_PREFIX(c));
|
||||
apply_mask(&cp);
|
||||
|
||||
if (prefix_same(&cp, &p))
|
||||
count++;
|
||||
|
||||
if (count >= 2)
|
||||
return;
|
||||
}
|
||||
|
||||
rib_add(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_CONNECT, 0,
|
||||
flags, &p, NULL, &nh, 0, zvrf->table_id, metric, 0, 0, 0);
|
||||
|
||||
@ -358,6 +382,9 @@ void connected_down(struct interface *ifp, struct connected *ifc)
|
||||
.vrf_id = ifp->vrf_id,
|
||||
};
|
||||
struct zebra_vrf *zvrf;
|
||||
uint32_t count = 0;
|
||||
struct listnode *cnode;
|
||||
struct connected *c;
|
||||
|
||||
zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);
|
||||
if (!zvrf) {
|
||||
@ -396,6 +423,26 @@ void connected_down(struct interface *ifp, struct connected *ifc)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possible to have X number of addresses
|
||||
* on a interface that all resolve to the same
|
||||
* network and mask. Find them and just
|
||||
* allow the deletion when are removing the last
|
||||
* one.
|
||||
*/
|
||||
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
||||
struct prefix cp;
|
||||
|
||||
PREFIX_COPY(&cp, CONNECTED_PREFIX(c));
|
||||
apply_mask(&cp);
|
||||
|
||||
if (prefix_same(&p, &cp))
|
||||
count++;
|
||||
|
||||
if (count >= 2)
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Same logic as for connected_up(): push the changes into the
|
||||
* head.
|
||||
|
Loading…
Reference in New Issue
Block a user