Skip to content

Commit

Permalink
route/nexthop: merge branch 'zstas:main'
Browse files Browse the repository at this point in the history
  • Loading branch information
thom311 committed Jul 31, 2023
2 parents eef0674 + beba5a1 commit bc8573d
Show file tree
Hide file tree
Showing 16 changed files with 1,154 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ test-suite.log
/src/nl-neigh-delete
/src/nl-neigh-list
/src/nl-neightbl-list
/src/nl-nh-list
/src/nl-pktloc-lookup
/src/nl-qdisc-add
/src/nl-qdisc-delete
Expand Down
8 changes: 8 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ libnlinclude_netlink_route_HEADERS = \
include/netlink/route/neightbl.h \
include/netlink/route/netconf.h \
include/netlink/route/nexthop.h \
include/netlink/route/nh.h \
include/netlink/route/pktloc.h \
include/netlink/route/qdisc.h \
include/netlink/route/route.h \
Expand Down Expand Up @@ -212,6 +213,7 @@ libnlinclude_netlink_cli_HEADERS = \
include/netlink/cli/link.h \
include/netlink/cli/mdb.h \
include/netlink/cli/neigh.h \
include/netlink/cli/nh.h \
include/netlink/cli/qdisc.h \
include/netlink/cli/route.h \
include/netlink/cli/rule.h \
Expand Down Expand Up @@ -253,6 +255,7 @@ noinst_HEADERS = \
include/linux-private/linux/netfilter/nfnetlink_log.h \
include/linux-private/linux/netfilter/nfnetlink_queue.h \
include/linux-private/linux/netlink.h \
include/linux-private/linux/nexthop.h \
include/linux-private/linux/pkt_cls.h \
include/linux-private/linux/pkt_sched.h \
include/linux-private/linux/rtnetlink.h \
Expand Down Expand Up @@ -436,6 +439,7 @@ lib_libnl_route_3_la_SOURCES = \
lib/route/neightbl.c \
lib/route/netconf.c \
lib/route/nexthop.c \
lib/route/nh.c \
lib/route/nexthop_encap.c \
lib/route/nh_encap_mpls.c \
lib/route/pktloc.c \
Expand Down Expand Up @@ -631,6 +635,7 @@ src_lib_libnl_cli_3_la_SOURCES = \
src/lib/exp.c \
src/lib/link.c \
src/lib/neigh.c \
src/lib/nh.c \
src/lib/qdisc.c \
src/lib/route.c \
src/lib/rule.c \
Expand Down Expand Up @@ -714,6 +719,7 @@ cli_programs = \
src/nl-neigh-delete \
src/nl-neigh-list \
src/nl-neightbl-list \
src/nl-nh-list \
src/nl-pktloc-lookup \
src/nl-qdisc-add \
src/nl-qdisc-delete \
Expand Down Expand Up @@ -813,6 +819,8 @@ src_nl_neigh_list_CPPFLAGS = $(src_cppflags)
src_nl_neigh_list_LDADD = $(src_ldadd)
src_nl_neightbl_list_CPPFLAGS = $(src_cppflags)
src_nl_neightbl_list_LDADD = $(src_ldadd)
src_nl_nh_list_CPPFLAGS = $(src_cppflags)
src_nl_nh_list_LDADD = $(src_ldadd)
src_nl_pktloc_lookup_CPPFLAGS = $(src_cppflags)
src_nl_pktloc_lookup_LDADD = $(src_ldadd)
src_nl_qdisc_add_CPPFLAGS = $(src_cppflags)
Expand Down
72 changes: 62 additions & 10 deletions include/linux-private/linux/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ enum {
NDA_MASTER,
NDA_LINK_NETNSID,
NDA_SRC_VNI,
NDA_PROTOCOL, /* Originator of entry */
NDA_NH_ID,
NDA_FDB_EXT_ATTRS,
NDA_FLAGS_EXT,
NDA_NDM_STATE_MASK,
NDA_NDM_FLAGS_MASK,
__NDA_MAX
};

Expand All @@ -37,13 +43,17 @@ enum {
* Neighbor Cache Entry Flags
*/

#define NTF_USE 0x01
#define NTF_SELF 0x02
#define NTF_MASTER 0x04
#define NTF_PROXY 0x08 /* == ATF_PUBL */
#define NTF_EXT_LEARNED 0x10
#define NTF_OFFLOADED 0x20
#define NTF_ROUTER 0x80
#define NTF_USE (1 << 0)
#define NTF_SELF (1 << 1)
#define NTF_MASTER (1 << 2)
#define NTF_PROXY (1 << 3) /* == ATF_PUBL */
#define NTF_EXT_LEARNED (1 << 4)
#define NTF_OFFLOADED (1 << 5)
#define NTF_STICKY (1 << 6)
#define NTF_ROUTER (1 << 7)
/* Extended flags under NDA_FLAGS_EXT: */
#define NTF_EXT_MANAGED (1 << 0)
#define NTF_EXT_LOCKED (1 << 1)

/*
* Neighbor Cache Entry States.
Expand All @@ -61,9 +71,27 @@ enum {
#define NUD_PERMANENT 0x80
#define NUD_NONE 0x00

/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change
and make no address resolution or NUD.
NUD_PERMANENT also cannot be deleted by garbage collectors.
/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no
* address resolution or NUD.
*
* NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true
* for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier
* down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED
* flagged entries explicitly are (which is also consistent with the routing
* subsystem).
*
* When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
* states don't make sense and thus are ignored. Such entries don't age and
* can roam.
*
* NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
* of a user space control plane, and automatically refreshed so that (if
* possible) they remain in NUD_REACHABLE state.
*
* NTF_EXT_LOCKED flagged bridge FDB entries are entries generated by the
* bridge in response to a host trying to communicate via a locked bridge port
* with MAB enabled. Their purpose is to notify user space that a host requires
* authentication.
*/

struct nda_cacheinfo {
Expand Down Expand Up @@ -132,6 +160,7 @@ enum {
NDTPA_QUEUE_LENBYTES, /* u32 */
NDTPA_MCAST_REPROBES, /* u32 */
NDTPA_PAD,
NDTPA_INTERVAL_PROBE_TIME_MS, /* u64, msecs */
__NDTPA_MAX
};
#define NDTPA_MAX (__NDTPA_MAX - 1)
Expand Down Expand Up @@ -169,4 +198,27 @@ enum {
};
#define NDTA_MAX (__NDTA_MAX - 1)

/* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
* - FDB_NOTIFY_BIT - notify on activity/expire for any entry
* - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
*/
enum {
FDB_NOTIFY_BIT = (1 << 0),
FDB_NOTIFY_INACTIVE_BIT = (1 << 1)
};

/* embedded into NDA_FDB_EXT_ATTRS:
* [NDA_FDB_EXT_ATTRS] = {
* [NFEA_ACTIVITY_NOTIFY]
* ...
* }
*/
enum {
NFEA_UNSPEC,
NFEA_ACTIVITY_NOTIFY,
NFEA_DONT_REFRESH,
__NFEA_MAX
};
#define NFEA_MAX (__NFEA_MAX - 1)

#endif
104 changes: 104 additions & 0 deletions include/linux-private/linux/nexthop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _LINUX_NEXTHOP_H
#define _LINUX_NEXTHOP_H

#include <linux/types.h>

struct nhmsg {
unsigned char nh_family;
unsigned char nh_scope; /* return only */
unsigned char nh_protocol; /* Routing protocol that installed nh */
unsigned char resvd;
unsigned int nh_flags; /* RTNH_F flags */
};

/* entry in a nexthop group */
struct nexthop_grp {
__u32 id; /* nexthop id - must exist */
__u8 weight; /* weight of this nexthop */
__u8 resvd1;
__u16 resvd2;
};

enum {
NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group
* default type if not specified
*/
NEXTHOP_GRP_TYPE_RES, /* resilient nexthop group */
__NEXTHOP_GRP_TYPE_MAX,
};

#define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)

enum {
NHA_UNSPEC,
NHA_ID, /* u32; id for nexthop. id == 0 means auto-assign */

NHA_GROUP, /* array of nexthop_grp */
NHA_GROUP_TYPE, /* u16 one of NEXTHOP_GRP_TYPE */
/* if NHA_GROUP attribute is added, no other attributes can be set */

NHA_BLACKHOLE, /* flag; nexthop used to blackhole packets */
/* if NHA_BLACKHOLE is added, OIF, GATEWAY, ENCAP can not be set */

NHA_OIF, /* u32; nexthop device */
NHA_GATEWAY, /* be32 (IPv4) or in6_addr (IPv6) gw address */
NHA_ENCAP_TYPE, /* u16; lwt encap type */
NHA_ENCAP, /* lwt encap data */

/* NHA_OIF can be appended to dump request to return only
* nexthops using given device
*/
NHA_GROUPS, /* flag; only return nexthop groups in dump */
NHA_MASTER, /* u32; only return nexthops with given master dev */

NHA_FDB, /* flag; nexthop belongs to a bridge fdb */
/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */

/* nested; resilient nexthop group attributes */
NHA_RES_GROUP,
/* nested; nexthop bucket attributes */
NHA_RES_BUCKET,

__NHA_MAX,
};

#define NHA_MAX (__NHA_MAX - 1)

enum {
NHA_RES_GROUP_UNSPEC,
/* Pad attribute for 64-bit alignment. */
NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC,

/* u16; number of nexthop buckets in a resilient nexthop group */
NHA_RES_GROUP_BUCKETS,
/* clock_t as u32; nexthop bucket idle timer (per-group) */
NHA_RES_GROUP_IDLE_TIMER,
/* clock_t as u32; nexthop unbalanced timer */
NHA_RES_GROUP_UNBALANCED_TIMER,
/* clock_t as u64; nexthop unbalanced time */
NHA_RES_GROUP_UNBALANCED_TIME,

__NHA_RES_GROUP_MAX,
};

#define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1)

enum {
NHA_RES_BUCKET_UNSPEC,
/* Pad attribute for 64-bit alignment. */
NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC,

/* u16; nexthop bucket index */
NHA_RES_BUCKET_INDEX,
/* clock_t as u64; nexthop bucket idle time */
NHA_RES_BUCKET_IDLE_TIME,
/* u32; nexthop id assigned to the nexthop bucket */
NHA_RES_BUCKET_NH_ID,

__NHA_RES_BUCKET_MAX,
};

#define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1)

#endif
Loading

0 comments on commit bc8573d

Please sign in to comment.