summaryrefslogtreecommitdiffstats
path: root/src/plugins/linux-cp/lcp_router.c
AgeCommit message (Collapse)AuthorFilesLines
2024-01-10linux-cp: fix route prefix constructionAlexander Skorichenko1-1/+1
Prevent comparison ops for uninitialized IPv6 prefix bytes. Type: fix Change-Id: I440fea7f0725769406ad348eb3402a98c593dc3c Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
2023-07-11linux-cp: Basic MPLS support.Adrian Pistol1-10/+158
1) Imports ENCAP_MPLS labels from IPv4/IPv6 routes. Note that this requires libnl 3.6.0 or newer. In previous patches, the fib_path_ext_t had a path ID of -1. After a long investigation, it turned out to be caused by route weight being set to 0. There is a comment explaining more details. 2) Handles MPLS routes. MPLS routes were wrongly added as IPv4 routes before. POP and SWAP are now both supported. All the routes are installed as NON-EOS and EOS routes, as the Linux kernel does not differentiate. EOS POP used in PHP uses the next-hop address family to determine the resulting address family. This patch is sufficient for P setups. PE setups with implicit null should also function okay, as long as a seperate label gets programmed per address family. PE setups with explicit null will also forward packets, but punting is a bit odd and needs MPLS input enabled on the LCP host device. 3) Propagate MPLS input state to LCP Pair and Linux. Since the Linux kernel uses the MPLS routes itself, the LCP pair tap needs MPLS enabled to allow host originated packets. This also syncs the Linux `net.mpls.conf.<host_if>.input` sysctl to allow punted packets to have MPLS labels, mostly explicit nulls. In addition, a special feature is enabled to cross connect MPLS packets coming from Linux directly to interface-output untouched. Make sure to enable MPLS/add a table in VPP first and load the MPLS kernel modules!! Type: feature Change-Id: Ie4184bb4cc96905bf8b483a27e7ca6d251697374 Signed-off-by: Adrian Pistol <vifino@posteo.net> Signed-off-by: Pim van Pelt <pim@ipng.nl>
2023-06-05linux-cp: Fix add vs update on routesPim van Pelt1-51/+51
Linux uses NLM_F_REPLACE in the netlink message to signal a FIB update The code invariably does a FIB update for IPv4 and a addition for IPv6. Without this fix, the following: ip route add 2001:db8::/48 via 2001:db8::1 ip route replace 2001:db8::/48 via 2001:db8::2 ends up as two separate FIB entries in VPP. With the fix, there will be one FIB entry (the second one with nexthop ::2). Type: fix Change-Id: I8f98d6ded52ae0c60bfddaa7fc39acbbaa19d34a Signed-off-by: Pim van Pelt <pim@ipng.nl>
2023-05-26linux-cp: update adjs for subifs too when mac changesAlexander Chernavin1-4/+21
The plugin creates and manages adjacencies for the physical interface in each interface pair (they are part of the x-connect feature). When a link update notification is received from the host system, MAC address of the corresponding physical interface is updated (as needed) as well as previously created adjacencies for it (because a new rewrite string needs to be generated). Subinterfaces inherit MAC address from the parent interface. When MAC address of the parent interface changes, it also implies MAC address change for its subinterfaces. The problem is that this is currently not considered in the plugin. After MAC address update on the parent interface, packets sent from subinterfaces might have wrong source MAC address. For example, IPv6 Neighbor Solicitation messages will be sent with the wrong (previous) MAC address and neighbor discovery will fail. With this fix, when the plugin updates adjacencies for a physical interface, it will also update adjacencies for the subinterfaces with existing interface pair. Type: fix Change-Id: Ia5f617197e33cb79b9b025c02c2c126c31a551ec Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2023-04-14linux-cp: Handle RTA_VIA routes.Adrian Pistol1-2/+3
RTA_VIA allows routes to have a next-hop in a different address family. This commit makes linux-cp import those types of routes correctly, instead of importing the routes without a gateway. This uses rtnl_route_nh_get_gateway, which is available since libnl 3.4.0 (Oct. 9, 2017). Even Debian Stretch has it via backports. Type: fix Change-Id: I06297c700461ba7874eb8baf9355bd40990b3121 Signed-off-by: Adrian Pistol <vifino@posteo.net>
2023-02-02linux-cp: fix auto-sub-intStanislav Zaikin1-0/+4
lcp_itf_pair_pool could grew during sub-interface creation. Type: fix Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com> Change-Id: Ideafe392f9bb2b418ce9d6faa4f08dfe26f4a273
2022-11-23linux-cp: fix FIB_ENTRY_FLAG_ATTACHEDAlexander Skorichenko1-0/+10
Type: fix     Fib entries for attached routes when sourced from FIB_SOURCE_API or FIB_SOURCE_CLI get the FIB_ENTRY_FLAG_ATTACHED flag raised on the source. Such a route added from linux-cp doesn't get this flag.     Fix this flag for linux-cp sources by passing it to the fib entry's update/create function in lcp_router_route_add(). Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com> Change-Id: I24278ef86886cfee8a14acb250fb6992a754cc3c
2022-08-23linux-cp: handle AF_BRIDGE neighborsMatthew Smith1-2/+8
Type: improvement VPP crashes when a linux-cp tap is added to a bridge on the host system because rtnl_neigh_get_dst() returns NULL for the neighbor message that is sent by the kernel. Check for NULL before trying to use the address from a neighbor in a netlink message. Signed-off-by: Matthew Smith <mgsmith@netgate.com> Change-Id: I8a683d815a09620df9c0cc76e18df39828428e2c Signed-off-by: Matthew Smith <mgsmith@netgate.com>
2022-04-26linux-cp: sync addr and neigh only for lcp interfacesStanislav Zaikin1-3/+30
Type: fix Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com> Change-Id: I792467b73449074e59c4232b1f82d134c399624c
2022-04-08linux-cp: fix setting mtu on hardware interfacesMatthew Smith1-1/+1
Type: fix Fixes: 616447c39231 In lcp_router_link_mtu(), either vnet_hw_interface_set_mtu() or vnet_sw_interface_set_mtu() is called, based on whether this appears to be a physical interface. The test to determine whether this is true was incorrect and probably never worked right so vnet_sw_interface_set_mtu() was always being called. This causes some breakage with Recent changes to code which manages interface MTUs. Fix the test so the right function is called. Change-Id: I1ecccbce37d5a1e53b2349ed40f3d0d27eb03569 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
2022-03-29linux-cp: handle ipv4 routes when link goes down on subifAlexander Chernavin1-17/+43
Type: improvement Currently, the plugin can monitor link state changes on hardware interfaces for which a linux-cp pair exists. When the link goes down on one of the hardware interfaces, the plugin processes IPv4 routes that resolve through that interface according to the configurations: del-static-on-link-down and del-dynamic-on-link-down. The problem is that link state changes are not signaled for subinterfaces and the code that handles IPv4 routes is not triggered. When the link on a hardware interface goes down, it implies that subinterfaces added to that interface also will have the link in the down state. With this change, when the link goes down on a hardware interface, iterate over subinterfaces added to the interface and apply the same logic of routes processing as for hardware interfaces. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I97337d2e328437c73f2d99a00737768778f197a1
2022-03-29linux-cp: add support for table flush if multiple interfacesAlexander Chernavin1-15/+39
Type: improvement lcp_router_table_flush() is used to remove routes from the given route table if they are resolved through the given interface with specified FIB source. Currently, if you need to remove routes from a route table that are resolved through one of the interfaces from a vector, the function has to be executed for every interface from the vector. Every execution walks the route table again. With this change, lcp_router_table_flush() accepts a vector of interfaces. Thus, the function can walk a single route table once and delete routes that resolve through one of the interfaces from the vector. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I6d99384064d279dea24bb4dc1790a1af943be41c
2022-03-25linux-cp: handle ipv4 routes when link goes downAlexander Chernavin1-0/+60
Type: improvement Currently, when the link goes down on an interface, routes that resolve through that interface and created with Nexthop API are removed by the kernel. However, IPv4 routes remain in the FIB because the kernel doesn't send any notifications about that. And for the plugin working with user-space applications that create routes in the kernel using Nexthop API there should be a mechanism to synchronize the FIB and the kernel in this case. With this change, add two new startup configuration options to the plugin to be able to control what should happen with static and dynamic routes managed by the plugin on link down: - del-static-on-link-down (disabled by default, delete routes created with the linux-cp static FIB source on link down), - del-dynamic-on-link-down (disabled by default, delete routes created with the linux-cp dynamic FIB source on link down). Then, monitor link state changes on interfaces for which a linux-cp pair exists. If the link goes down on one of the interfaces, process routes that resolve through that interface according to the new configurations. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I0fbaeeca3f3d1fcd22e8eebb08a0a4a3d0dfe5b8
2022-03-07linux-cp: handle ipv4 routes when interface is disabledAlexander Chernavin1-2/+88
Type: improvement Currently, when an interface is brought down administratively, IPv4 routes that resolve through that interface remain in the FIB. However, the kernel removes those routes but doesn't send any notifications about that. Desynchronization between the kernel and VPP happens. With this change, when a notification received from the kernel indicating that an interface was brought down, in addition to bringing the VPP interface down, walk the IPv4 FIB bound to that interface and remove any entries that resolve through that interface and were added with one of the linux-cp FIB sources. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I0cd14bb63c9e6616ae1c5739b17c3bf33b186bc2
2022-03-04linux-cp: ignore neighbors if ip addr is multicastAlexander Chernavin1-0/+17
Type: improvement When dump of neighbors is requested, the replies will also include neighbor entries for IPv6 multicast addresses: GigabitEthernet0/8/0 S ff02::16 33:33:00:00:00:16 GigabitEthernet0/8/0 S ff02::1:ff76:7135 33:33:ff:76:71:35 GigabitEthernet0/8/0 S ff02::2 33:33:00:00:00:02 Such entries are not reported in netlink notification messages and VPP is unlikely to use these. With this change, ignore neighbor entries when the IP address is a multicast address. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: Ic712aa4904f1d559f31fd89ff4541268e2340f84
2022-03-03linux-cp: detect and delete stale entries after syncAlexander Chernavin1-0/+95
Type: improvement During synchronization, only the current actual set of entries is loaded. If some entries are no longer present in the set being loaded but present in VPP, they should be removed to fully syncronize. With this change, add handlers for sync begin and end events. Begin handlers will mark the entries as stale. End handlers will remove the entries that are still marked as stale. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: I4f7e872af3e1c9ffa6c63bcc3984ec76def1bb43
2022-03-03linux-cp: make check of message ts null-tolerantAlexander Chernavin1-0/+3
Type: improvement For some message types, timestamps are checked on netlink message to decide whether the message should be applied. For notification messages timestamps are expected to be always available. With this change, before accessing the timestamp, make sure the message info object that carries it is not null. If it is null, pass the check. This is to be ready to process dump replies that will not need the timestamp check and will have the message info object set to null. Signed-off-by: Alexander Chernavin <achernavin@netgate.com> Change-Id: Ic7211c0d451d72f6a5248898b3a8f8e0bca8f7aa
2022-03-02linux-cp: lcp fib fixesVladimir Ratnikov1-5/+6
Some possible side effects for multicast routes appears to be in lcp_router_table_add_or_lock. so ff00/8 route will be processed for ospf purposes the right way Ignore IPv6 kernel routes Skip adding auto routes into FIB Type: fix Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com> Change-Id: I35f73d629a7fffca7f7d4547adc2549b72c2048f
2022-01-28linux-cp: Linux Control Plane Netlink ListenerNeale Ranns1-0/+1053
Type: feature please see FEATURE.yaml for details. Signed-off-by: Neale Ranns <nranns@cisco.com> Signed-off-by: Matthew Smith <mgsmith@netgate.com> Signed-off-by: Jon Loeliger <jdl@netgate.com> Signed-off-by: Pim van Pelt <pim@ipng.nl> Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: I6255fd9953d0b03e6b4fe75b67a6845a7c206f74 Signed-off-by: Pim van Pelt <pim@ipng.nl>