Bake in the required Linux kernel UAPI headers so that OVN builds
correctly against older kernel header versions that may be missing
certain definitions.

Signed-off-by: Alexandra Rukomoinikova <[email protected]>
---
 build-aux/initial-tab-whitelist        |   5 +-
 controller/neighbor-exchange-netlink.c |   6 -
 controller/nexthop-exchange.c          |  10 --
 include/automake.mk                    |   2 +-
 include/linux/automake.mk              |   3 +
 include/linux/neighbour.h              | 229 +++++++++++++++++++++++++
 include/linux/nexthop.h                | 157 +++++++++++++++++
 m4/ovn.m4                              |  15 --
 8 files changed, 393 insertions(+), 34 deletions(-)
 create mode 100644 include/linux/automake.mk
 create mode 100644 include/linux/neighbour.h
 create mode 100644 include/linux/nexthop.h

diff --git a/build-aux/initial-tab-whitelist b/build-aux/initial-tab-whitelist
index 2dd02b657..07b3c5927 100644
--- a/build-aux/initial-tab-whitelist
+++ b/build-aux/initial-tab-whitelist
@@ -3,10 +3,11 @@
 \.mk$
 \.png$
 \.sln$
-^ovs/
-^third-party/
 ^debian/rules.modules$
 ^debian/rules$
+^include/linux/
+^ovs/
+^third-party/
 ^\.gitmodules$
 ^utilities/containers/Makefile
 ^tests/ovn-inc-proc-graph-dump.at
diff --git a/controller/neighbor-exchange-netlink.c 
b/controller/neighbor-exchange-netlink.c
index f01bfda5b..3bd1df699 100644
--- a/controller/neighbor-exchange-netlink.c
+++ b/controller/neighbor-exchange-netlink.c
@@ -31,12 +31,6 @@ VLOG_DEFINE_THIS_MODULE(neighbor_exchange_netlink);
 
 #define NETNL_REQ_BUFFER_SIZE 128
 
-/* NTF_EXT_LEARNED was introduced in Linux v3.19, define it if
- * not available. */
-#ifndef NTF_EXT_LEARNED
-#define NTF_EXT_LEARNED (1 << 4)
-#endif
-
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
 
 /* Inspired from route_table_dump_one_table() in OVS. */
diff --git a/controller/nexthop-exchange.c b/controller/nexthop-exchange.c
index 8718b893f..711a9e01b 100644
--- a/controller/nexthop-exchange.c
+++ b/controller/nexthop-exchange.c
@@ -39,16 +39,6 @@ static int nh_table_parse__(struct ofpbuf *, size_t ofs,
 static void nh_populate_grp_pointers(struct nexthop_entry *, struct hmap *);
 static uint32_t nexthop_entry_hash(uint32_t id);
 
-/* The following definition should be available in Linux 6.12 and might be
- * missing if we have older headers. */
-#ifndef HAVE_NH_GRP_WEIGHT
-static uint16_t
-nexthop_grp_weight(const struct nexthop_grp *entry)
-{
-    return entry->weight + 1;
-}
-#endif
-
 /* Populates 'nexthops' with all nexthop entries
  * (struct nexthop_entry) with fdb flag set that exist in the table. */
 void
diff --git a/include/automake.mk b/include/automake.mk
index 9e8403f8d..7ea35f817 100644
--- a/include/automake.mk
+++ b/include/automake.mk
@@ -1,2 +1,2 @@
 include include/ovn/automake.mk
-
+include include/linux/automake.mk
diff --git a/include/linux/automake.mk b/include/linux/automake.mk
new file mode 100644
index 000000000..94a73c16d
--- /dev/null
+++ b/include/linux/automake.mk
@@ -0,0 +1,3 @@
+noinst_HEADERS += \
+    include/linux/neighbour.h \
+    include/linux/nexthop.h
diff --git a/include/linux/neighbour.h b/include/linux/neighbour.h
new file mode 100644
index 000000000..c34a81245
--- /dev/null
+++ b/include/linux/neighbour.h
@@ -0,0 +1,229 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI__LINUX_NEIGHBOUR_H
+#define _UAPI__LINUX_NEIGHBOUR_H
+
+#include <linux/types.h>
+#include <linux/netlink.h>
+
+struct ndmsg {
+       __u8            ndm_family;
+       __u8            ndm_pad1;
+       __u16           ndm_pad2;
+       __s32           ndm_ifindex;
+       __u16           ndm_state;
+       __u8            ndm_flags;
+       __u8            ndm_type;
+};
+
+enum {
+       NDA_UNSPEC,
+       NDA_DST,
+       NDA_LLADDR,
+       NDA_CACHEINFO,
+       NDA_PROBES,
+       NDA_VLAN,
+       NDA_PORT,
+       NDA_VNI,
+       NDA_IFINDEX,
+       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
+};
+
+#define NDA_MAX (__NDA_MAX - 1)
+
+/*
+ *     Neighbor Cache Entry Flags
+ */
+
+#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)
+#define NTF_EXT_EXT_VALIDATED  (1 << 2)
+
+/*
+ *     Neighbor Cache Entry States.
+ */
+
+#define NUD_INCOMPLETE 0x01
+#define NUD_REACHABLE  0x02
+#define NUD_STALE      0x04
+#define NUD_DELAY      0x08
+#define NUD_PROBE      0x10
+#define NUD_FAILED     0x20
+
+/* Dummy states */
+#define NUD_NOARP      0x40
+#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. 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.
+ *
+ * NTF_EXT_EXT_VALIDATED flagged neighbor entries were externally validated by
+ * a user space control plane. The kernel will not remove or invalidate them,
+ * but it can probe them and notify user space when they become reachable.
+ */
+
+struct nda_cacheinfo {
+       __u32           ndm_confirmed;
+       __u32           ndm_used;
+       __u32           ndm_updated;
+       __u32           ndm_refcnt;
+};
+
+/*****************************************************************
+ *             Neighbour tables specific messages.
+ *
+ * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
+ * NLM_F_DUMP flag set. Every neighbour table configuration is
+ * spread over multiple messages to avoid running into message
+ * size limits on systems with many interfaces. The first message
+ * in the sequence transports all not device specific data such as
+ * statistics, configuration, and the default parameter set.
+ * This message is followed by 0..n messages carrying device
+ * specific parameter sets.
+ * Although the ordering should be sufficient, NDTA_NAME can be
+ * used to identify sequences. The initial message can be identified
+ * by checking for NDTA_CONFIG. The device specific messages do
+ * not contain this TLV but have NDTPA_IFINDEX set to the
+ * corresponding interface index.
+ *
+ * To change neighbour table attributes, send RTM_SETNEIGHTBL
+ * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
+ * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
+ * otherwise. Device specific parameter sets can be changed by
+ * setting NDTPA_IFINDEX to the interface index of the corresponding
+ * device.
+ ****/
+
+struct ndt_stats {
+       __u64           ndts_allocs;
+       __u64           ndts_destroys;
+       __u64           ndts_hash_grows;
+       __u64           ndts_res_failed;
+       __u64           ndts_lookups;
+       __u64           ndts_hits;
+       __u64           ndts_rcv_probes_mcast;
+       __u64           ndts_rcv_probes_ucast;
+       __u64           ndts_periodic_gc_runs;
+       __u64           ndts_forced_gc_runs;
+       __u64           ndts_table_fulls;
+};
+
+enum {
+       NDTPA_UNSPEC,
+       NDTPA_IFINDEX,                  /* u32, unchangeable */
+       NDTPA_REFCNT,                   /* u32, read-only */
+       NDTPA_REACHABLE_TIME,           /* u64, read-only, msecs */
+       NDTPA_BASE_REACHABLE_TIME,      /* u64, msecs */
+       NDTPA_RETRANS_TIME,             /* u64, msecs */
+       NDTPA_GC_STALETIME,             /* u64, msecs */
+       NDTPA_DELAY_PROBE_TIME,         /* u64, msecs */
+       NDTPA_QUEUE_LEN,                /* u32 */
+       NDTPA_APP_PROBES,               /* u32 */
+       NDTPA_UCAST_PROBES,             /* u32 */
+       NDTPA_MCAST_PROBES,             /* u32 */
+       NDTPA_ANYCAST_DELAY,            /* u64, msecs */
+       NDTPA_PROXY_DELAY,              /* u64, msecs */
+       NDTPA_PROXY_QLEN,               /* u32 */
+       NDTPA_LOCKTIME,                 /* u64, msecs */
+       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)
+
+struct ndtmsg {
+       __u8            ndtm_family;
+       __u8            ndtm_pad1;
+       __u16           ndtm_pad2;
+};
+
+struct ndt_config {
+       __u16           ndtc_key_len;
+       __u16           ndtc_entry_size;
+       __u32           ndtc_entries;
+       __u32           ndtc_last_flush;        /* delta to now in msecs */
+       __u32           ndtc_last_rand;         /* delta to now in msecs */
+       __u32           ndtc_hash_rnd;
+       __u32           ndtc_hash_mask;
+       __u32           ndtc_hash_chain_gc;
+       __u32           ndtc_proxy_qlen;
+};
+
+enum {
+       NDTA_UNSPEC,
+       NDTA_NAME,                      /* char *, unchangeable */
+       NDTA_THRESH1,                   /* u32 */
+       NDTA_THRESH2,                   /* u32 */
+       NDTA_THRESH3,                   /* u32 */
+       NDTA_CONFIG,                    /* struct ndt_config, read-only */
+       NDTA_PARMS,                     /* nested TLV NDTPA_* */
+       NDTA_STATS,                     /* struct ndt_stats, read-only */
+       NDTA_GC_INTERVAL,               /* u64, msecs */
+       NDTA_PAD,
+       __NDTA_MAX
+};
+#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
diff --git a/include/linux/nexthop.h b/include/linux/nexthop.h
new file mode 100644
index 000000000..bc49baf4a
--- /dev/null
+++ b/include/linux/nexthop.h
@@ -0,0 +1,157 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_NEXTHOP_H
+#define _UAPI_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    weight_high;    /* high order bits of weight */
+       __u16   resvd2;
+};
+
+static inline __u16 nexthop_grp_weight(const struct nexthop_grp *entry)
+{
+       return ((entry->weight_high << 8) | entry->weight) + 1;
+}
+
+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)
+
+#define NHA_OP_FLAG_DUMP_STATS         BIT(0)
+#define NHA_OP_FLAG_DUMP_HW_STATS      BIT(1)
+
+/* Response OP_FLAGS. */
+#define NHA_OP_FLAG_RESP_GRP_RESVD_0   BIT(31) /* Dump clears resvd fields. */
+
+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,
+
+       /* u32; operation-specific flags */
+       NHA_OP_FLAGS,
+
+       /* nested; nexthop group stats */
+       NHA_GROUP_STATS,
+
+       /* u32; nexthop hardware stats enable */
+       NHA_HW_STATS_ENABLE,
+
+       /* u32; read-only; whether any driver collects HW stats */
+       NHA_HW_STATS_USED,
+
+       __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)
+
+enum {
+       NHA_GROUP_STATS_UNSPEC,
+
+       /* nested; nexthop group entry stats */
+       NHA_GROUP_STATS_ENTRY,
+
+       __NHA_GROUP_STATS_MAX,
+};
+
+#define NHA_GROUP_STATS_MAX    (__NHA_GROUP_STATS_MAX - 1)
+
+enum {
+       NHA_GROUP_STATS_ENTRY_UNSPEC,
+
+       /* u32; nexthop id of the nexthop group entry */
+       NHA_GROUP_STATS_ENTRY_ID,
+
+       /* uint; number of packets forwarded via the nexthop group entry */
+       NHA_GROUP_STATS_ENTRY_PACKETS,
+
+       /* uint; number of packets forwarded via the nexthop group entry in
+        * hardware
+        */
+       NHA_GROUP_STATS_ENTRY_PACKETS_HW,
+
+       __NHA_GROUP_STATS_ENTRY_MAX,
+};
+
+#define NHA_GROUP_STATS_ENTRY_MAX      (__NHA_GROUP_STATS_ENTRY_MAX - 1)
+
+#endif
diff --git a/m4/ovn.m4 b/m4/ovn.m4
index 93a959224..bd71aee84 100644
--- a/m4/ovn.m4
+++ b/m4/ovn.m4
@@ -586,18 +586,3 @@ AC_DEFUN([OVS_CHECK_LINUX_NETLINK], [
     [Define to 1 if struct nla_bitfield32 is available.])])
 ])
 
-dnl OVN_CHECK_LINUX_NEXTHOP_WEIGHT
-dnl
-dnl Configure Linux netlink nexthop compat.
-AC_DEFUN([OVN_CHECK_LINUX_NEXTHOP_WEIGHT], [
-    save_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([#include <linux/nexthop.h>], [
-          struct nexthop_grp grp = { 0 };
-          nexthop_grp_weight(&grp);
-      ])],
-      [AC_DEFINE([HAVE_NH_GRP_WEIGHT], [1],
-      [Define to 1 if nexthop_grp_weight() is available.])])
-    CFLAGS="$save_CFLAGS"
-  ])
-- 
2.48.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to