diff options
author | Donald Sharp <sharpd@nvidia.com> | 2021-04-20 01:23:45 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2021-05-03 15:17:22 +0200 |
commit | 92980561382fc04380414a6e2f6ca6746c2fe5e9 (patch) | |
tree | eeace4d5b093fa275f564ac4dfc300f3930cfe9c /zebra/connected.c | |
parent | Merge pull request #8566 from rubensfig/isis_metricstyle (diff) | |
download | frr-92980561382fc04380414a6e2f6ca6746c2fe5e9.tar.xz frr-92980561382fc04380414a6e2f6ca6746c2fe5e9.zip |
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>
Diffstat (limited to 'zebra/connected.c')
-rw-r--r-- | zebra/connected.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/zebra/connected.c b/zebra/connected.c index 6f405ca1b..1e03f8b63 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -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) { @@ -397,6 +424,26 @@ void connected_down(struct interface *ifp, struct connected *ifc) } /* + * 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. */ |