Blame SOURCES/0021-build-update-ebtables.h-from-kernel-and-drop-local-u.patch

05e71a
From b96b42e4ad9c47bf2a511905bca4e52bb4cee16d Mon Sep 17 00:00:00 2001
05e71a
From: Jan Engelhardt <jengelh@inai.de>
05e71a
Date: Wed, 6 Jun 2018 13:36:25 +0200
05e71a
Subject: [PATCH] build: update ebtables.h from kernel and drop local unused
05e71a
 copy
05e71a
05e71a
Revert 66a97018a31eed416c6a25d051ea172e4d65be1b partly so as to use
05e71a
<linux/netfilter_bridge/ebtables.h> again and import a new ebtables.h
05e71a
from the kernel tree that has the "revision" field.
05e71a
05e71a
With this, include/ebtables.h is (again) used by no source file, and
05e71a
so can be removed.
05e71a
05e71a
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
05e71a
Signed-off-by: Florian Westphal <fw@strlen.de>
05e71a
Signed-off-by: Phil Sutter <psutter@redhat.com>
05e71a
---
05e71a
 include/ebtables.h                        | 286 ----------------------
05e71a
 include/ebtables_u.h                      |   2 +-
05e71a
 include/linux/netfilter_bridge/ebtables.h |  27 +-
05e71a
 3 files changed, 20 insertions(+), 295 deletions(-)
05e71a
 delete mode 100644 include/ebtables.h
05e71a
05e71a
diff --git a/include/ebtables.h b/include/ebtables.h
05e71a
deleted file mode 100644
05e71a
index 9bbedbb72eea5..0000000000000
05e71a
--- a/include/ebtables.h
05e71a
+++ /dev/null
05e71a
@@ -1,286 +0,0 @@
05e71a
-/*
05e71a
- *  ebtables
05e71a
- *
05e71a
- *	Authors:
05e71a
- *	Bart De Schuymer		<bdschuym@pandora.be>
05e71a
- *
05e71a
- *  ebtables.c,v 2.0, April, 2002
05e71a
- *
05e71a
- *  This code is stongly inspired on the iptables code which is
05e71a
- *  Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
05e71a
- */
05e71a
-
05e71a
-/* Local copy of the kernel file, needed for Sparc64 support */
05e71a
-#ifndef __LINUX_BRIDGE_EFF_H
05e71a
-#define __LINUX_BRIDGE_EFF_H
05e71a
-#include <linux/if.h>
05e71a
-#include <linux/netfilter_bridge.h>
05e71a
-#include <linux/if_ether.h>
05e71a
-
05e71a
-#define EBT_TABLE_MAXNAMELEN 32
05e71a
-#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
05e71a
-#define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN
05e71a
-#define EBT_EXTENSION_MAXNAMELEN 31
05e71a
-
05e71a
-/* verdicts >0 are "branches" */
05e71a
-#define EBT_ACCEPT   -1
05e71a
-#define EBT_DROP     -2
05e71a
-#define EBT_CONTINUE -3
05e71a
-#define EBT_RETURN   -4
05e71a
-#define NUM_STANDARD_TARGETS   4
05e71a
-/* ebtables target modules store the verdict inside an int. We can
05e71a
- * reclaim a part of this int for backwards compatible extensions.
05e71a
- * The 4 lsb are more than enough to store the verdict. */
05e71a
-#define EBT_VERDICT_BITS 0x0000000F
05e71a
-
05e71a
-struct ebt_counter
05e71a
-{
05e71a
-	uint64_t pcnt;
05e71a
-	uint64_t bcnt;
05e71a
-};
05e71a
-
05e71a
-struct ebt_replace
05e71a
-{
05e71a
-	char name[EBT_TABLE_MAXNAMELEN];
05e71a
-	unsigned int valid_hooks;
05e71a
-	/* nr of rules in the table */
05e71a
-	unsigned int nentries;
05e71a
-	/* total size of the entries */
05e71a
-	unsigned int entries_size;
05e71a
-	/* start of the chains */
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	uint64_t hook_entry[NF_BR_NUMHOOKS];
05e71a
-#else
05e71a
-	struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
05e71a
-#endif
05e71a
-	/* nr of counters userspace expects back */
05e71a
-	unsigned int num_counters;
05e71a
-	/* where the kernel will put the old counters */
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	uint64_t counters;
05e71a
-	uint64_t entries;
05e71a
-#else
05e71a
-	struct ebt_counter *counters;
05e71a
-	char *entries;
05e71a
-#endif
05e71a
-};
05e71a
-
05e71a
-struct ebt_entries {
05e71a
-	/* this field is always set to zero
05e71a
-	 * See EBT_ENTRY_OR_ENTRIES.
05e71a
-	 * Must be same size as ebt_entry.bitmask */
05e71a
-	unsigned int distinguisher;
05e71a
-	/* the chain name */
05e71a
-	char name[EBT_CHAIN_MAXNAMELEN];
05e71a
-	/* counter offset for this chain */
05e71a
-	unsigned int counter_offset;
05e71a
-	/* one standard (accept, drop, return) per hook */
05e71a
-	int policy;
05e71a
-	/* nr. of entries */
05e71a
-	unsigned int nentries;
05e71a
-	/* entry list */
05e71a
-	char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
05e71a
-};
05e71a
-
05e71a
-/* used for the bitmask of struct ebt_entry */
05e71a
-
05e71a
-/* This is a hack to make a difference between an ebt_entry struct and an
05e71a
- * ebt_entries struct when traversing the entries from start to end.
05e71a
- * Using this simplifies the code alot, while still being able to use
05e71a
- * ebt_entries.
05e71a
- * Contrary, iptables doesn't use something like ebt_entries and therefore uses
05e71a
- * different techniques for naming the policy and such. So, iptables doesn't
05e71a
- * need a hack like this.
05e71a
- */
05e71a
-#define EBT_ENTRY_OR_ENTRIES 0x01
05e71a
-/* these are the normal masks */
05e71a
-#define EBT_NOPROTO 0x02
05e71a
-#define EBT_802_3 0x04
05e71a
-#define EBT_SOURCEMAC 0x08
05e71a
-#define EBT_DESTMAC 0x10
05e71a
-#define EBT_F_MASK (EBT_NOPROTO | EBT_802_3 | EBT_SOURCEMAC | EBT_DESTMAC \
05e71a
-   | EBT_ENTRY_OR_ENTRIES)
05e71a
-
05e71a
-#define EBT_IPROTO 0x01
05e71a
-#define EBT_IIN 0x02
05e71a
-#define EBT_IOUT 0x04
05e71a
-#define EBT_ISOURCE 0x8
05e71a
-#define EBT_IDEST 0x10
05e71a
-#define EBT_ILOGICALIN 0x20
05e71a
-#define EBT_ILOGICALOUT 0x40
05e71a
-#define EBT_INV_MASK (EBT_IPROTO | EBT_IIN | EBT_IOUT | EBT_ILOGICALIN \
05e71a
-   | EBT_ILOGICALOUT | EBT_ISOURCE | EBT_IDEST)
05e71a
-
05e71a
-struct ebt_entry_match
05e71a
-{
05e71a
-	union {
05e71a
-		struct {
05e71a
-			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
-			uint8_t revision;
05e71a
-		};
05e71a
-		struct ebt_match *match;
05e71a
-	} u;
05e71a
-	/* size of data */
05e71a
-	unsigned int match_size;
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	unsigned int pad;
05e71a
-#endif
05e71a
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
05e71a
-};
05e71a
-
05e71a
-struct ebt_entry_watcher
05e71a
-{
05e71a
-	union {
05e71a
-		struct {
05e71a
-			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
-			uint8_t revision;
05e71a
-		};
05e71a
-		struct ebt_watcher *watcher;
05e71a
-	} u;
05e71a
-	/* size of data */
05e71a
-	unsigned int watcher_size;
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	unsigned int pad;
05e71a
-#endif
05e71a
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
05e71a
-};
05e71a
-
05e71a
-struct ebt_entry_target
05e71a
-{
05e71a
-	union {
05e71a
-		struct {
05e71a
-			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
-			uint8_t revision;
05e71a
-		};
05e71a
-		struct ebt_target *target;
05e71a
-	} u;
05e71a
-	/* size of data */
05e71a
-	unsigned int target_size;
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	unsigned int pad;
05e71a
-#endif
05e71a
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
05e71a
-};
05e71a
-
05e71a
-#define EBT_STANDARD_TARGET "standard"
05e71a
-struct ebt_standard_target
05e71a
-{
05e71a
-	struct ebt_entry_target target;
05e71a
-	int verdict;
05e71a
-#ifdef KERNEL_64_USERSPACE_32
05e71a
-	unsigned int pad;
05e71a
-#endif
05e71a
-};
05e71a
-
05e71a
-/* one entry */
05e71a
-struct ebt_entry {
05e71a
-	/* this needs to be the first field */
05e71a
-	unsigned int bitmask;
05e71a
-	unsigned int invflags;
05e71a
-	uint16_t ethproto;
05e71a
-	/* the physical in-dev */
05e71a
-	char in[IFNAMSIZ];
05e71a
-	/* the logical in-dev */
05e71a
-	char logical_in[IFNAMSIZ];
05e71a
-	/* the physical out-dev */
05e71a
-	char out[IFNAMSIZ];
05e71a
-	/* the logical out-dev */
05e71a
-	char logical_out[IFNAMSIZ];
05e71a
-	unsigned char sourcemac[ETH_ALEN];
05e71a
-	unsigned char sourcemsk[ETH_ALEN];
05e71a
-	unsigned char destmac[ETH_ALEN];
05e71a
-	unsigned char destmsk[ETH_ALEN];
05e71a
-	/* sizeof ebt_entry + matches */
05e71a
-	unsigned int watchers_offset;
05e71a
-	/* sizeof ebt_entry + matches + watchers */
05e71a
-	unsigned int target_offset;
05e71a
-	/* sizeof ebt_entry + matches + watchers + target */
05e71a
-	unsigned int next_offset;
05e71a
-	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
05e71a
-};
05e71a
-
05e71a
-/* {g,s}etsockopt numbers */
05e71a
-#define EBT_BASE_CTL            128
05e71a
-
05e71a
-#define EBT_SO_SET_ENTRIES      (EBT_BASE_CTL)
05e71a
-#define EBT_SO_SET_COUNTERS     (EBT_SO_SET_ENTRIES+1)
05e71a
-#define EBT_SO_SET_MAX          (EBT_SO_SET_COUNTERS+1)
05e71a
-
05e71a
-#define EBT_SO_GET_INFO         (EBT_BASE_CTL)
05e71a
-#define EBT_SO_GET_ENTRIES      (EBT_SO_GET_INFO+1)
05e71a
-#define EBT_SO_GET_INIT_INFO    (EBT_SO_GET_ENTRIES+1)
05e71a
-#define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO+1)
05e71a
-#define EBT_SO_GET_MAX          (EBT_SO_GET_INIT_ENTRIES+1)
05e71a
-
05e71a
-/* blatently stolen from ip_tables.h
05e71a
- * fn returns 0 to continue iteration */
05e71a
-#define EBT_MATCH_ITERATE(e, fn, args...)                   \
05e71a
-({                                                          \
05e71a
-	unsigned int __i;                                   \
05e71a
-	int __ret = 0;                                      \
05e71a
-	struct ebt_entry_match *__match;                    \
05e71a
-	                                                    \
05e71a
-	for (__i = sizeof(struct ebt_entry);                \
05e71a
-	     __i < (e)->watchers_offset;                    \
05e71a
-	     __i += __match->match_size +                   \
05e71a
-	     sizeof(struct ebt_entry_match)) {              \
05e71a
-		__match = (void *)(e) + __i;                \
05e71a
-		                                            \
05e71a
-		__ret = fn(__match , ## args);              \
05e71a
-		if (__ret != 0)                             \
05e71a
-			break;                              \
05e71a
-	}                                                   \
05e71a
-	if (__ret == 0) {                                   \
05e71a
-		if (__i != (e)->watchers_offset)            \
05e71a
-			__ret = -EINVAL;                    \
05e71a
-	}                                                   \
05e71a
-	__ret;                                              \
05e71a
-})
05e71a
-
05e71a
-#define EBT_WATCHER_ITERATE(e, fn, args...)                 \
05e71a
-({                                                          \
05e71a
-	unsigned int __i;                                   \
05e71a
-	int __ret = 0;                                      \
05e71a
-	struct ebt_entry_watcher *__watcher;                \
05e71a
-	                                                    \
05e71a
-	for (__i = e->watchers_offset;                      \
05e71a
-	     __i < (e)->target_offset;                      \
05e71a
-	     __i += __watcher->watcher_size +               \
05e71a
-	     sizeof(struct ebt_entry_watcher)) {            \
05e71a
-		__watcher = (void *)(e) + __i;              \
05e71a
-		                                            \
05e71a
-		__ret = fn(__watcher , ## args);            \
05e71a
-		if (__ret != 0)                             \
05e71a
-			break;                              \
05e71a
-	}                                                   \
05e71a
-	if (__ret == 0) {                                   \
05e71a
-		if (__i != (e)->target_offset)              \
05e71a
-			__ret = -EINVAL;                    \
05e71a
-	}                                                   \
05e71a
-	__ret;                                              \
05e71a
-})
05e71a
-
05e71a
-#define EBT_ENTRY_ITERATE(entries, size, fn, args...)       \
05e71a
-({                                                          \
05e71a
-	unsigned int __i;                                   \
05e71a
-	int __ret = 0;                                      \
05e71a
-	struct ebt_entry *__entry;                          \
05e71a
-	                                                    \
05e71a
-	for (__i = 0; __i < (size);) {                      \
05e71a
-		__entry = (void *)(entries) + __i;          \
05e71a
-		__ret = fn(__entry , ## args);              \
05e71a
-		if (__ret != 0)                             \
05e71a
-			break;                              \
05e71a
-		if (__entry->bitmask != 0)                  \
05e71a
-			__i += __entry->next_offset;        \
05e71a
-		else                                        \
05e71a
-			__i += sizeof(struct ebt_entries);  \
05e71a
-	}                                                   \
05e71a
-	if (__ret == 0) {                                   \
05e71a
-		if (__i != (size))                          \
05e71a
-			__ret = -EINVAL;                    \
05e71a
-	}                                                   \
05e71a
-	__ret;                                              \
05e71a
-})
05e71a
-
05e71a
-#endif
05e71a
diff --git a/include/ebtables_u.h b/include/ebtables_u.h
05e71a
index 7adc5a2f33329..3235bf5967055 100644
05e71a
--- a/include/ebtables_u.h
05e71a
+++ b/include/ebtables_u.h
05e71a
@@ -25,7 +25,7 @@
05e71a
 #define EBTABLES_U_H
05e71a
 #include <netinet/in.h>
05e71a
 #include <netinet/ether.h>
05e71a
-#include <ebtables.h>
05e71a
+#include <linux/netfilter_bridge/ebtables.h>
05e71a
 #include <linux/netfilter/x_tables.h>
05e71a
 
05e71a
 #ifndef IPPROTO_SCTP
05e71a
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
05e71a
index 19a64448c648e..5be75f282cd20 100644
05e71a
--- a/include/linux/netfilter_bridge/ebtables.h
05e71a
+++ b/include/linux/netfilter_bridge/ebtables.h
05e71a
@@ -1,3 +1,4 @@
05e71a
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
05e71a
 /*
05e71a
  *  ebtables
05e71a
  *
05e71a
@@ -6,19 +7,20 @@
05e71a
  *
05e71a
  *  ebtables.c,v 2.0, April, 2002
05e71a
  *
05e71a
- *  This code is stongly inspired on the iptables code which is
05e71a
+ *  This code is strongly inspired by the iptables code which is
05e71a
  *  Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
05e71a
  */
05e71a
 
05e71a
 #ifndef __LINUX_BRIDGE_EFF_H
05e71a
 #define __LINUX_BRIDGE_EFF_H
05e71a
+#include <linux/types.h>
05e71a
 #include <linux/if.h>
05e71a
 #include <linux/netfilter_bridge.h>
05e71a
-#include <linux/if_ether.h>
05e71a
 
05e71a
 #define EBT_TABLE_MAXNAMELEN 32
05e71a
 #define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
05e71a
 #define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN
05e71a
+#define EBT_EXTENSION_MAXNAMELEN 31
05e71a
 
05e71a
 /* verdicts >0 are "branches" */
05e71a
 #define EBT_ACCEPT   -1
05e71a
@@ -35,8 +37,8 @@ struct xt_match;
05e71a
 struct xt_target;
05e71a
 
05e71a
 struct ebt_counter {
05e71a
-	uint64_t pcnt;
05e71a
-	uint64_t bcnt;
05e71a
+	__u64 pcnt;
05e71a
+	__u64 bcnt;
05e71a
 };
05e71a
 
05e71a
 struct ebt_replace {
05e71a
@@ -119,7 +121,10 @@ struct ebt_entries {
05e71a
 
05e71a
 struct ebt_entry_match {
05e71a
 	union {
05e71a
-		char name[EBT_FUNCTION_MAXNAMELEN];
05e71a
+		struct {
05e71a
+			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
+			uint8_t revision;
05e71a
+		};
05e71a
 		struct xt_match *match;
05e71a
 	} u;
05e71a
 	/* size of data */
05e71a
@@ -129,7 +134,10 @@ struct ebt_entry_match {
05e71a
 
05e71a
 struct ebt_entry_watcher {
05e71a
 	union {
05e71a
-		char name[EBT_FUNCTION_MAXNAMELEN];
05e71a
+		struct {
05e71a
+			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
+			uint8_t revision;
05e71a
+		};
05e71a
 		struct xt_target *watcher;
05e71a
 	} u;
05e71a
 	/* size of data */
05e71a
@@ -139,7 +147,10 @@ struct ebt_entry_watcher {
05e71a
 
05e71a
 struct ebt_entry_target {
05e71a
 	union {
05e71a
-		char name[EBT_FUNCTION_MAXNAMELEN];
05e71a
+		struct {
05e71a
+			char name[EBT_EXTENSION_MAXNAMELEN];
05e71a
+			uint8_t revision;
05e71a
+		};
05e71a
 		struct xt_target *target;
05e71a
 	} u;
05e71a
 	/* size of data */
05e71a
@@ -265,4 +276,4 @@ struct ebt_entry {
05e71a
 	__ret;                                              \
05e71a
 })
05e71a
 
05e71a
-#endif
05e71a
+#endif /* __LINUX_BRIDGE_EFF_H */
05e71a
-- 
05e71a
2.21.0
05e71a