Straight forward addition/removal of IPv4 and IPv6 addresses on interfaces. One thing I noticed, which isn't a concern but an unfortunate issue, looking at the following sequence: ip addr add 10.0.1.1/30 dev e0 debug linux-cp/nl addr_add: netlink route/addr: add idx 1488 family inet local 10.0.1.1/30 flags 0x0080 (permanent) warn linux-cp/nl dispatch: ignored route/route: add family inet type 2 proto 2 table 255 dst 10.0.1.1 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: add family inet type 1 proto 2 table 254 dst 10.0.1.0/30 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: add family inet type 3 proto 2 table 255 dst 10.0.1.0 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: add family inet type 3 proto 2 table 255 dst 10.0.1.3 nexthops { idx 1488 } ping 10.0.1.2 debug linux-cp/nl neigh_add: netlink route/neigh: add idx 1488 family inet lladdr 68:05:ca:32:45:94 dst 10.0.1.2 state 0x0002 (reachable) flags 0x0000 notice linux-cp/nl neigh_add: Added 10.0.1.2 lladdr 68:05:ca:32:45:94 iface TenGigabitEthernet3/0/0 ip addr del 10.0.1.1/30 dev e0 debug linux-cp/nl addr_del: netlink route/addr: del idx 1488 family inet local 10.0.1.1/30 flags 0x0080 (permanent) notice linux-cp/nl addr_del: Deleted 10.0.1.1/30 iface TenGigabitEthernet3/0/0 warn linux-cp/nl dispatch: ignored route/route: del family inet type 1 proto 2 table 254 dst 10.0.1.0/30 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: del family inet type 3 proto 2 table 255 dst 10.0.1.3 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: del family inet type 3 proto 2 table 255 dst 10.0.1.0 nexthops { idx 1488 } warn linux-cp/nl dispatch: ignored route/route: del family inet type 2 proto 2 table 255 dst 10.0.1.1 nexthops { idx 1488 } debug linux-cp/nl neigh_del: netlink route/neigh: del idx 1488 family inet lladdr 68:05:ca:32:45:94 dst 10.0.1.2 state 0x0002 (reachable) flags 0x0000 error linux-cp/nl neigh_del: Failed 10.0.1.2 iface TenGigabitEthernet3/0/0 It is this very last message that's a bit of a concern -- the ping brought the lladdr into the neighbor cache; and the subsequent address deletion first removed the address, then all the typical local routes (the connected, the broadcast, the network, and the self/local); but then as well explicitly deleted the neighbor, which is correct behavior for Linux, except that VPP already invalidates the neighbor cache and adds/removes the connected routes for example in ip/ip4_forward.c L826-L830 and L583. I predict more of these false positive 'errors' like the one on neigh_del() beacuse interface/route addition/deletion is slightly different in VPP than in Linux. I may have to reclassify the errors as warnings otherwise.
96 lines
2.8 KiB
C
96 lines
2.8 KiB
C
/*
|
|
* Copyright (c) 2021 Cisco and/or its affiliates.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at:
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <vlib/vlib.h>
|
|
#include <plugins/lcpng/lcpng.h>
|
|
|
|
#include <netlink/msg.h>
|
|
#include <netlink/netlink.h>
|
|
#include <netlink/socket.h>
|
|
#include <netlink/route/link.h>
|
|
#include <netlink/route/route.h>
|
|
#include <netlink/route/neighbour.h>
|
|
#include <netlink/route/addr.h>
|
|
#include <netlink/route/link/vlan.h>
|
|
|
|
typedef enum nl_event_type_t_
|
|
{
|
|
NL_EVENT_READ,
|
|
NL_EVENT_READ_ERR,
|
|
} nl_event_type_t;
|
|
|
|
#define NL_RX_BUF_SIZE_DEF (1 << 27) /* 128 MB */
|
|
#define NL_TX_BUF_SIZE_DEF (1 << 18) /* 256 kB */
|
|
#define NL_BATCH_SIZE_DEF (1 << 11) /* 2048 */
|
|
#define NL_BATCH_DELAY_MS_DEF 50 /* 50 ms, max 20 batch/s */
|
|
|
|
#define NL_DBG(...) vlib_log_debug (lcp_nl_main.nl_logger, __VA_ARGS__);
|
|
#define NL_INFO(...) vlib_log_info (lcp_nl_main.nl_logger, __VA_ARGS__);
|
|
#define NL_NOTICE(...) vlib_log_notice (lcp_nl_main.nl_logger, __VA_ARGS__);
|
|
#define NL_WARN(...) vlib_log_warn (lcp_nl_main.nl_logger, __VA_ARGS__);
|
|
#define NL_ERROR(...) vlib_log_err (lcp_nl_main.nl_logger, __VA_ARGS__);
|
|
|
|
/* struct type to hold context on the netlink message being processed.
|
|
*/
|
|
typedef struct nl_msg_info
|
|
{
|
|
struct nl_msg *msg;
|
|
f64 ts;
|
|
} nl_msg_info_t;
|
|
|
|
typedef struct lcp_nl_netlink_namespace
|
|
{
|
|
struct nl_sock *sk_route;
|
|
nl_msg_info_t *nl_msg_queue;
|
|
uword clib_file_index; // clib file that holds the netlink socket for this
|
|
// namespace
|
|
u32 clib_file_lcp_refcnt; // number of interfaces watched in the this netlink
|
|
// namespace
|
|
u8 netns_name[LCP_NS_LEN]; // namespace name (can be empty, for 'self')
|
|
} lcp_nl_netlink_namespace_t;
|
|
|
|
typedef struct lcp_nl_main
|
|
{
|
|
vlib_log_class_t nl_logger;
|
|
/* TODO(pim): nl_ns should become a list, one for each unique namespace we
|
|
* created LCP pairs in.
|
|
*/
|
|
lcp_nl_netlink_namespace_t nl_ns;
|
|
|
|
u32 rx_buf_size;
|
|
u32 tx_buf_size;
|
|
u32 batch_size;
|
|
u32 batch_delay_ms;
|
|
|
|
} lcp_nl_main_t;
|
|
extern lcp_nl_main_t lcp_nl_main;
|
|
|
|
u8 *format_nl_object (u8 *s, va_list *args);
|
|
|
|
/* Functions from lcpng_nl_sync.c
|
|
*/
|
|
void lcp_nl_neigh_add (struct rtnl_neigh *rn);
|
|
void lcp_nl_neigh_del (struct rtnl_neigh *rn);
|
|
void lcp_nl_addr_add (struct rtnl_addr *ra);
|
|
void lcp_nl_addr_del (struct rtnl_addr *ra);
|
|
|
|
/*
|
|
* fd.io coding-style-patch-verification: ON
|
|
*
|
|
* Local Variables:
|
|
* eval: (c-set-style "gnu")
|
|
* End:
|
|
*/
|