Commit Graph

438 Commits

Author SHA1 Message Date
Donald Sharp
46d725f76b lib, zebra: Ensure that the ifp->node exists
On removal, ensure that the ifp->node is set to a null
pointer so that FRR does not use data after freed.
In addition ensure that the ifp->node exists before
attempting to free it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-28 10:13:16 -04:00
anlan_cs
41414503e4 zebra: Fix missing VRF flag
1. No any configuration in FRR, and `ip link add vrf1 type vrf ...`.
Currently, everything is ok.

2.  `ip link del vrf1`.
`zebra` will wrongly/redundantly notify clients to add "vrf1" as a normal
interface after correct deletion of "vrf1".

```
ZEBRA: [KMXEB-K771Y] netlink_parse_info: netlink-listen (NS 0) type RTM_DELLINK(17), len=588, seq=0, pid=0
ZEBRA: [TDJW2-B9KJW] RTM_DELLINK for vrf1(93) <- Wrongly as normal interface, not vrf
ZEBRA: [WEEJX-M4HA0] interface vrf1 vrf vrf1(93) index 93 is now inactive.
ZEBRA: [NXAHW-290AC] MESSAGE: ZEBRA_INTERFACE_DELETE vrf1 vrf vrf1(93)
ZEBRA: [H97XA-ABB3A] MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL vrf1 VRF Id 93 -> 0
ZEBRA: [HP8PZ-7D6D2] MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD vrf1 VRF Id 93 -> 0 <-
ZEBRA: [Y6R2N-EF2N4] interface vrf1 is being deleted from the system
ZEBRA: [KNFMR-AFZ53] RTM_DELLINK for VRF vrf1(93)
ZEBRA: [P0CZ5-RF5FH] VRF vrf1 id 93 is now inactive
ZEBRA: [XC3P3-1DG4D] MESSAGE: ZEBRA_VRF_DELETE vrf1
ZEBRA: [ZMS2F-6K837] VRF vrf1 id 4294967295 deleted
OSPF: [JKWE3-97M3J] Zebra: interface add vrf1 vrf default[0] index 0 flags 480 metric 0 mtu 65575 speed 0 <- Wrongly add interface
```

`if_handle_vrf_change()` moved the interface from specific vrf to default
vrf. But it doesn't skip interface of vrf type. So, the wrong/redundant
add operation is done.

Note, the wrong add operation is regarded as an normal interface because
the `ifp->status` is cleared too early, so it is without VRF flag
( `ZEBRA_INTERFACE_VRF_LOOPBACK` ). Now, ospfd will initialize `ifp->type`
to `OSPF_IFTYPE_BROADCAST`.

3. `ip link add vrf1 type vrf ...`, add "vrf1" again. FRR will be with
wrong display:

```
interface vrf1
 ip ospf network broadcast
exit
```

Here, zebra will send `ZEBRA_INTERFACE_ADD` again for "vrf1" with
correct `ifp->status`, so it will be updated into vrf type. But
it can't update `ifp->type` from `OSPF_IFTYPE_BROADCAST` to
`OSPF_IFTYPE_LOOPBACK` because it had been already configured in above
step 2.

Two changes to fix it:

1. Skip the procedure of switching VRF for interfaces of vrf type.
It means, don't send `ZEBRA_INTERFACE_ADD` to clients when deleting vrf.

2. Put the deletion of this flag at the last.
It means, clients should get correct `ifp->status`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-05-01 20:21:37 +08:00
Jafar Al-Gharaibeh
bd2711d251
Merge pull request #12959 from leonshaw/fix/zif-link-nsid
zebra: Add link_nsid to zebra interface
2023-04-11 16:38:33 -05:00
Donald Sharp
e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
5f6eaa9b96 *: Convert a bunch of thread_XX to event_XX
Convert these functions:

thread_getrusage
thread_cmd_init
thread_consumed_time
thread_timer_to_hhmmss
thread_is_scheduled
thread_ignore_late_timer

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Xiao Liang
af19624b00 zebra: Add link_nsid to zebra interface
Create VRF and interfaces:

    ip netns add vrf1
    ip link add veth1 index 100 type veth
    ip link add link veth1 veth1.200 type vlan id 200
    ip link set veth1.200 netns vrf1
    ip -n vrf1 link add veth2 index 100 type veth

After reloading zebra, "show interface veth1.200" shows wrong parent
interface:

    test# show interface veth1.200
    Interface veth1.200 is down
      ...
      Parent interface: veth2

This is because veth1.200 and veth1 are in different netns, and veth2
happens to have the same ifindex as veth1, in the same netns of
veth1.200.
When looking for parent, link-ifindex 100 should be looked up within
link-netns, rather than that of the child interface.

Add link_nsid to zebra interface, so that the <link_nsid, link_ifindex>
pair can uniquely identify the link interface.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2023-03-08 09:57:18 +08:00
Donald Sharp
8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Olivier Dugeon
e2b958ecbc
Merge pull request #12494 from louis-6wind/ext_admin_group
lib,zebra,isisd: add support for extended admin group RFC7308
2023-02-15 09:42:03 +01:00
Stephen Worley
0bbad9d19a zebra: clang-format style fixes
clang-format style fixes

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Sharath Ramamurthy
9c21cf68bf zebra: Add ifdump vty json extension for vxlan/vni
This patch adds dump for vxlan/vni for vxlan devices in if_dump_vty_json

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Sharath Ramamurthy
9464e5b865 zebra: Bug fixes in fdb read for flooded traffic and remote fdb cleanup upon vni removal
This patch addresses following issues,
- When the VLAN-VNI mapping is configured via a map and not using
  individual VXLAN interfaces, upon removal of a VNI ensure that the
  remote FDB entries are uninstalled correctly.

- When VNI configuration is performed using VLAN-VNI mapping (i.e., without
  individual VXLAN interfaces) and flooded traffic is handled via multicast,
  the multicast group corresponding to the VNI needs to be explicitly read
  from the bridge FDB. This is relevant in the case of netlink interface to
  the kernel and for the scenario where a new VNI is provisioned or comes up.

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Sharath Ramamurthy
4a08e69746 zebra: Bug fixes in vtysh doc string, mcast group handling and vni deletion handling with single vxlan device
This patch addresses following bug fixes

- Fix vtysh doc string in "show evpn access-vlan..." command
- Multicast group handling was little complex. This change avoids calling
  multiple functions and directly calls the zebra_vxlan_if_update_vni for
  mcast group updates.
- When a vlan-vni map is removed, the removed vni deletion was happening
  in FRR with SVD config. This was resulting in stale vni and not
  resulting propagation of the vni deletion.
  During vni cleanup (zebra_vxlan_if_vni_clean) zebra_vxlan_if_vni_del
  was called for vni delete which is not correct. We should be calling
  zebra_vxlan_if_vni_entry_del for the given vni entry.

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Sharath Ramamurthy
efde4f2561 zebra: Refactoring changes for zebra_evpn_map_vlan zebra_evpn_from_svi and zl3vni_from_svi
Today to find the vni for a given (vlan, bridge) we walk over all interfaces
and filter the vxlan device associated with the bridge. With multiple vlan aware
bridge changes, we can derive the vni directly by looking up the hash table i.e.
the vlan_table of the associated (vlan, bridge) which would give the vni.

During vrf_terminate() call zebra_l2_bridge_if_cleanup if the interface
that we are removing is of type bridge. In this case, we walk over all
the vlan<->access_bd association and clean them up.

zebra_evpn_t is modified to record (vlan, bridge) details and the
corresponding vty is modified to print the same.
zevpn_bridge_if_set and zl3vni_bridge_if_set is used to set/unset the
association.

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Sharath Ramamurthy
784d88aa14 zebra: multiple vlan aware bridge datastructure changes and vxlan device iftype derivation from netlink
This change set introduces data structure changes required for multiple vlan aware bridge
functionality. A new structure zebra_l2_bridge_if encapsulates the vlan to access_bd
association of the bridge. A vlan_table hash_table is used to record each instance
of the vlan to access_bd of the bridge via zebra_l2_bridge_vlan structure.

vxlan iftype derivation: netlink attribute IFLA_VXLAN_COLLECT_METADATA is used
to derive the iftype of the vxlan device. If the attribute is present, then the
vxlan interface is treated as single vxlan device, otherwise it would default to
traditional vxlan device.

zebra_vxlan_check_readd_vtep, zebra_vxlan_dp_network_mac_add/del is modified to
be vni aware.

mac_fdb_read_for_bridge - is modified to be (vlan, bridge) aware

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Sharath Ramamurthy
8d30ff3b5e zebra: data structure changes for single vxlan device
This changeset introduces the data structure changes needed for
single vxlan device functionality. A new struct zebra_vxlan_vni_info
encodes the iftype and vni information for vxlan device.

The change addresses related access changes of the new data structure
fields from different files

zebra_vty is modified to take care of the vni dump information according
to the new vni data structure for vxlan devices.

Signed-off-by: Sharath Ramamurthy <sramamurthy@nvidia.com>
2023-02-13 18:12:04 -05:00
Louis Scalbert
158332617d lib,yang,zebra: add extended admin-group support
Add the support of Extended Admin-Group (RFC7308) to the zebra interface
link-params Traffic-Engineering context.

Extended admin-groups can be configured with the affinity-map:

> affinity-map blue bit-position 221
> int eth-rt1
>  link-params
>   affinity blue
>  exit-link-params

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-02-10 11:31:05 +01:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Rafael Zalamena
ab80e474f2 zebra: fix possible null dereference
Don't attempt to dereference `ifp` directly if it might be null: there
is a check right before this usage: `ifp ? ifp->info : NULL`.

In this context it should be safe to assume `ifp` is not NULL because
the only caller of this function checks that for this `ifindex`. For
consistency we'll check for null anyway in case this ever changes (and
with this the coverity scan warning gets silenced).

Found by Coverity Scan (CID 1519776)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-19 10:32:18 -03:00
Mark Stapp
c0ce4875ff zebra: use real MTYPEs for various objects
Don't use MTYPE_TMP for many things in zebra: add specific
mem types.

Signed-off-by: Mark Stapp <mjs@labn.net>
2022-12-05 10:55:35 -05:00
Donatas Abraitis
35c46a8718 zebra: Use mpls enable, not mpls when generating a config
If we enable MPLS for an interface via sysctl, we should write `mpls enable`,
not `mpls`.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-28 11:14:06 +02:00
Siger Yang
c317d3f246
zebra: traffic control state management
This allows Zebra to manage QDISC, TCLASS, TFILTER in kernel and do cleaning
jobs when it starts up.

Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-11-22 22:35:35 +08:00
Donald Sharp
d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
David Lamparter
89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Louis Scalbert
2e2dc4f024 lib,zebra: do not enable link-params when a link-params command fails
A given interface has no enabled link-params context. If a link-params
configuration command fails, the link-params is wrongly enabled:

> r4(config-link-params)# no enable
> r4(config-link-params)# delay
>   (0-16777215)  Average delay in micro-second as decimal (0...16777215)
> r4(config-link-params)# delay 50 min 300 max 500
> Average delay should be comprise between Min (300) and Max (500) delay
> r4(config-link-params)# do sh run zebra
> (...)
> interface eth-rt1
> link-params
>  enable
> exit-link-params

link-params are enabled if and only if the interface structure has a
valid link_params pointer. Before checking the command validity,
if_link_params_get() is called to retrieve the link-params pointer.
However, this function initializes the pointer if it is NULL.

Only use if_link_params_get() to retrieve the pointer to avoid
confusion. In command setting functions, initialize the link_params
pointer if needed only after the validation of the command.

Fixes: 16f1b9e ("Update Traffic Engineering Support for OSPFD")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-17 11:02:56 +02:00
Siger Yang
449a30edf6
zebra: add tc netlink and dplane ops
This commit implements necessary netlink encoders for traffic control
including QDISC, TCLASS and TFILTER, and adds basic dplane operations.

Co-authored-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-08-11 02:32:43 +08:00
Donald Sharp
db1c2223fd zebra: Don't install connected routes multiple times into FRR
When moving an interface between vrf's we do not need
to install the connected routes multiple times.

eva# show ip route vrf all
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

VRF BLUE:
C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:10

VRF default:
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:00:10
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:00:10
eva# exit
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link add GREEN type vrf table 11000
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set GREEN up
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set dummy7 master GREEN
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> vtysh

Hello, this is FRRouting (version 8.4-dev).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

eva# show ip route vrf all
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

VRF GREEN:
C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:05

VRF default:
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:01:03
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:01:03
eva# exit
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo ip link set dummy7 nomaster
sharpd@eva ~/f/t/topotests (multiple_connected_installs)> sudo vtysh -c "show ip route vrf all"
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

VRF default:
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:22
C>* 4.5.6.7/32 is directly connected, dummy7, 00:00:08
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:22
sharpd@eva ~/f/t/topotests (multiple_connected_installs)>
 @  11 0:-*                                                                                                                                                         5h50m 0.06 24x1.9GHz 31.4G26% 426G70% 2022-08-08 13:49:24

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08 13:51:24 -04:00
Donald Sharp
39ffa8e8e8 zebra: Add a mpls enable interface node command
Allow individual interfaces to turn on/off the mpls subsystem
for it in linux.

sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls
net.mpls.conf.enp39s0.input = 0
sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "mpls enable"
sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls
net.mpls.conf.enp39s0.input = 1
sharpd@eva:~/frr9$ vtysh -c "conf" -c "int enp39s0" -c "no mpls enable"
sharpd@eva:~/frr9$ sudo sysctl -a | grep enp39s0 | grep mpls
net.mpls.conf.enp39s0.input = 0
sharpd@eva:~/frr9$

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08 09:15:22 -04:00
Donald Sharp
c87f5c2392 zebra: Notice when an interface is turned on w/ mpls and enable mpls subsystem
Currently when FRR starts up it queries the kernel to see if mpls is turned on.
If not FRR does not enable zebra's mpls subsection.  If at a later time mpls
is turned on, let's notice that an interface now is enabled for mpls( thus
implying that all the bits and bobs in the kernel are now setup properly ).

a) convert mpls_enabled to a bool
b) abstract a new function zebra_mpls_turned_on and call it
when FRR notices that an interface now has mpls enabled.
c) mpls_processq_init cannot fail, so actually notice that
and don't have special code to detect a failure.

New results:

sharpd@eva ~> vtysh -c "show zebra"
 OS                           Linux(5.10.0-12-amd64)
 ECMP Maximum                 128
 v4 Forwarding                On
 v6 Forwarding                On
 MPLS                         Off
 EVPN                         Off
 Kernel socket buffer size    90000000
 VRF                          l3mdev Available
 ASIC offload                 Unavailable
 RA                           Compiled in
 RFC 5549                     BGP is not using
 Kernel NHG                   Available
 v4 All LinkDown Routes       Off
 v4 Default LinkDown Routes   Off
 v6 All LinkDown Routes       Off
 v6 Default LinkDown Routes   Off
 v4 All MC Forwarding         On
 v4 Default MC Forwarding     Off
 v6 All MC Forwarding         On
 v6 Default MC Forwarding     Off

                            Route      Route      Neighbor   LSP        LSP
VRF                         Installs   Removals    Updates   Installs   Removals
default                           26          7          0          0          0
<turn on mpls_iptunnel and mpls_router modules in the kernel and then do this>:
sharpd@eva ~> sudo sysctl -w net.mpls.conf.enp39s0.input=1
[sudo] password for sharpd:
net.mpls.conf.enp39s0.input = 1
sharpd@eva ~> vtysh -c "show zebra"
 OS                           Linux(5.10.0-12-amd64)
 ECMP Maximum                 128
 v4 Forwarding                On
 v6 Forwarding                On
 MPLS                         On
 EVPN                         Off
 Kernel socket buffer size    90000000
 VRF                          l3mdev Available
 ASIC offload                 Unavailable
 RA                           Compiled in
 RFC 5549                     BGP is not using
 Kernel NHG                   Available
 v4 All LinkDown Routes       Off
 v4 Default LinkDown Routes   Off
 v6 All LinkDown Routes       Off
 v6 Default LinkDown Routes   Off
 v4 All MC Forwarding         On
 v4 Default MC Forwarding     Off
 v6 All MC Forwarding         On
 v6 Default MC Forwarding     Off

                            Route      Route      Neighbor   LSP        LSP
VRF                         Installs   Removals    Updates   Installs   Removals
default                           26          7          0          0          0
sharpd@eva ~>

I am doing this work because FRR keeps having operators not know about how
to properly use mpls.  Let's make FRR behave a bit better in this weird edge
case.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08 09:15:22 -04:00
Donald Sharp
e63831f133 zebra: Add IF_ZEBRA_DATA_X define
There are 2 defines IF_ZEBRA_MULTICAST_X and
IF_ZEBRA_SHUTDOWN_X macros that do the same
thing.  Combine into one.

Future commits will use the IF_ZEBRA_DATA_X macro
as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08 09:15:22 -04:00
Donald Sharp
f00b37e710 zebra: make rib_process_dplane_results own ctx freeing
The rib_process_dplane_results function was having each
sub function handler process the results and then
free the ctx.  Lot's of functionality that needs to remember
to free the context.  Let's just free it in the main loop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29 15:24:20 -04:00
Donald Sharp
385d37ab31 zebra: Add ability for netconf dplane to handle global values
Add the ability for the netconf dplane code to handle
the global NETCONFA_IFINDEX_DEFAULT and NETCONF_IFINDEX_ALL
values.  Then store our interested values when we get
them from the kernel as well as being able to display
them to the end operator.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27 16:30:20 -04:00
Donald Sharp
d53dc9bd81 zebra: Pass afi received for netconf updates
When Zebra receives the netconf update an afi is passed
let's seperate that out and track the v4/v6 specific data
to save and store appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27 15:26:13 -04:00
Donald Sharp
4c84aa5ebd zebra: mc_forwarding was being sent but not retrieved across dataplane
The mc_forwarding status for an interface was being sent but not
properly retrieved on the zebra master side of the dplane.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-27 15:04:21 -04:00
Donald Sharp
3689905d32 zebra: Add interface sysctl ignore on linkdown status
Add the ability to decode the ignore on linkdown nexthop
status for an interface.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:37 -04:00
Donald Sharp
382858d015 zebra: Move where zebra marks a nhg as uninstalled in fib
Currently the code is marking the nhg as uninstalled but not
causing that to flood up to the dependent nhgs:

nhg 3 is a group of 1/2
   1 -> interface A
   2 -> interface B

Suppose A goes down, old code would mark nhg 1 as !VALID and !INSTALLED.
Suppose B then goes down, old code would mark nhg 2 as !VALID and !INSTALLED
But would not mark nhg 3 as !VALID and !INSTALLED (sort of assuming that
it would just be cleaned up by NHG refcounts ).  I would prefer that
the code is pedantic about nhg 3 actually being removed from the system.

This code moves the setting of !INSTALLED into zebra_nhg.c where it
really belongs.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 14:47:19 -04:00
Donald Sharp
8b9b1d6043 zebra: On linux let interface data come in through netlink messaging
Consolidate on linux to using the netlink api for gathering all data
about a interface.  Leave this interface alone in the meantime for
other OS's.

This also has the side effect of reducing the amount of work
being done on linux in that FRR was handling shut/no shut
events 2 times.  Once for the ioctl question asked and
once for the netlink message received.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:34:30 -04:00
David Lamparter
7ca9c407ed zebra: clean up rtadv integration
Move a few things into places they actually belong, and reduce the
number of places we have `#ifdev HAVE_RTADV`.  Just overall code
prettification.

... I had actually done this quite a while ago while doing some other
random hacking and thought it more useful to not be sitting on it on my
disk...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-21 14:14:01 +02:00
G. Paul Ziemba
d029fe275c zebra/interface.c: allow link-param delay min <= avg <= max
RFC 7471 Section 4.2.7:
	It is possible for min delay and max delay to be the same value.

    Prior to this change, the code required min < avg < max. This
    change allows min == avg and avg == max.

    test case:

    interface eth-rt1
      link-params
        delay 8000 min 8000 max 8000

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2022-05-06 14:48:31 -07:00
Donald Sharp
4667220e3a *: Fix spelling of accidently
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:31:30 -04:00
Donald Sharp
d0438da6b0 zebra: Fix use after deletion event in freebsd
In the FreeBSD code if you delete the interface
and it has no configuration, the ifp pointer will
be deleted from the system *but* zebra continues
to dereference the just freed pointer.

==58624== Invalid read of size 1
==58624==    at 0x48539F3: strlcpy (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x2B0565: ifreq_set_name (ioctl.c:48)
==58624==    by 0x2B0565: if_get_flags (ioctl.c:416)
==58624==    by 0x2B2D9E: ifan_read (kernel_socket.c:455)
==58624==    by 0x2B2D9E: kernel_read (kernel_socket.c:1403)
==58624==    by 0x499F46E: thread_call (thread.c:2002)
==58624==    by 0x495D2B7: frr_run (libfrr.c:1196)
==58624==    by 0x2B40B8: main (main.c:471)
==58624==  Address 0x6baa7f0 is 64 bytes inside a block of size 432 free'd
==58624==    at 0x484ECDC: free (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x4953A64: if_delete (if.c:283)
==58624==    by 0x2A93C1: if_delete_update (interface.c:874)
==58624==    by 0x2B2DF3: ifan_read (kernel_socket.c:453)
==58624==    by 0x2B2DF3: kernel_read (kernel_socket.c:1403)
==58624==    by 0x499F46E: thread_call (thread.c:2002)
==58624==    by 0x495D2B7: frr_run (libfrr.c:1196)
==58624==    by 0x2B40B8: main (main.c:471)
==58624==  Block was alloc'd at
==58624==    at 0x4851381: calloc (in /usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==58624==    by 0x496A022: qcalloc (memory.c:116)
==58624==    by 0x49546BC: if_new (if.c:164)
==58624==    by 0x49546BC: if_create_name (if.c:218)
==58624==    by 0x49546BC: if_get_by_name (if.c:603)
==58624==    by 0x2B1295: ifm_read (kernel_socket.c:628)
==58624==    by 0x2A7FB6: interface_list (if_sysctl.c:129)
==58624==    by 0x2E99C8: zebra_ns_enable (zebra_ns.c:127)
==58624==    by 0x2E99C8: zebra_ns_init (zebra_ns.c:214)
==58624==    by 0x2B3FF2: main (main.c:401)
==58624==

Zebra needs to pass back whether or not the ifp pointer
was freed when if_delete_update is called and it should
then check in ifan_read as well as ifm_read that the
ifp pointer is still valid for use.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-24 20:48:24 -04:00
Stephen Worley
7140b00cb0 zebra: use SET/UNSET/CHECK/COND in protodown code
Use the SET/UNSET/CHECK/COND macros for flag bifields
where appropriate throught the protodown code base.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
00d57e6dd5 zebra: clear dplane flags on failure for protodown
Make sure we clear our dplane flags for SET/UNSET
on failure so that we try again.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
a3ea8493a8 zebra: simplify reason code printing in show
Simplify the code for printing the reason codes via
show command. Just remove the trailing comma last
before printing.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
3db9f2db2b zebra: cleanup protodown api logs
Cleanup the logs in the api for setting protodown on/off
that zapi and others use. Make them more useful to a user parsing
them after an issue.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
321c80d6b2 zebra: extern setting protodown reason directly
Extern the api for setting the protodown reason code
bitfield directly. Some places may want to completely update the
bitfield with more than one reason at a time.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
ab465d24bd zebra: only clear pd_reason on shutdown/sweep
Only clear protodown reason on shutdown/sweep, retain protodown
state.

This is to retain traditional and expected behavior with daemons
like vrrpd setting protodown. They expet it to be set on shutdown
and retained on bring up to prevent traffic from being dropped.

We must cleanup our reason code though to prevent us from blocking
others.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
e4d87b5894 zebra: remove old protodown dplane path
Remove the old protodown dplane path install on the main thread.
This is now dead code.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00
Stephen Worley
d89b300829 zebra: use a macro for check protodown
Add a helper macro for checking if interface is protodown,
typing this out is annoying.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 18:02:44 -05:00