1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef __LINUX_BRIDGE_EFF_H
14#define __LINUX_BRIDGE_EFF_H
15
16#include <linux/if.h>
17#include <linux/if_ether.h>
18#include <uapi/linux/netfilter_bridge/ebtables.h>
19
20
21#define EBT_MATCH 0
22#define EBT_NOMATCH 1
23
24struct ebt_match {
25 struct list_head list;
26 const char name[EBT_FUNCTION_MAXNAMELEN];
27 bool (*match)(const struct sk_buff *skb, const struct net_device *in,
28 const struct net_device *out, const struct xt_match *match,
29 const void *matchinfo, int offset, unsigned int protoff,
30 bool *hotdrop);
31 bool (*checkentry)(const char *table, const void *entry,
32 const struct xt_match *match, void *matchinfo,
33 unsigned int hook_mask);
34 void (*destroy)(const struct xt_match *match, void *matchinfo);
35 unsigned int matchsize;
36 u_int8_t revision;
37 u_int8_t family;
38 struct module *me;
39};
40
41struct ebt_watcher {
42 struct list_head list;
43 const char name[EBT_FUNCTION_MAXNAMELEN];
44 unsigned int (*target)(struct sk_buff *skb,
45 const struct net_device *in, const struct net_device *out,
46 unsigned int hook_num, const struct xt_target *target,
47 const void *targinfo);
48 bool (*checkentry)(const char *table, const void *entry,
49 const struct xt_target *target, void *targinfo,
50 unsigned int hook_mask);
51 void (*destroy)(const struct xt_target *target, void *targinfo);
52 unsigned int targetsize;
53 u_int8_t revision;
54 u_int8_t family;
55 struct module *me;
56};
57
58struct ebt_target {
59 struct list_head list;
60 const char name[EBT_FUNCTION_MAXNAMELEN];
61
62 unsigned int (*target)(struct sk_buff *skb,
63 const struct net_device *in, const struct net_device *out,
64 unsigned int hook_num, const struct xt_target *target,
65 const void *targinfo);
66 bool (*checkentry)(const char *table, const void *entry,
67 const struct xt_target *target, void *targinfo,
68 unsigned int hook_mask);
69 void (*destroy)(const struct xt_target *target, void *targinfo);
70 unsigned int targetsize;
71 u_int8_t revision;
72 u_int8_t family;
73 struct module *me;
74};
75
76
77struct ebt_chainstack {
78 struct ebt_entries *chaininfo;
79 struct ebt_entry *e;
80 unsigned int n;
81};
82
83struct ebt_table_info {
84
85 unsigned int entries_size;
86 unsigned int nentries;
87
88 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
89
90 struct ebt_chainstack **chainstack;
91 char *entries;
92 struct ebt_counter counters[0] ____cacheline_aligned;
93};
94
95struct ebt_table {
96 struct list_head list;
97 char name[EBT_TABLE_MAXNAMELEN];
98 struct ebt_replace_kernel *table;
99 unsigned int valid_hooks;
100 rwlock_t lock;
101
102
103 int (*check)(const struct ebt_table_info *info,
104 unsigned int valid_hooks);
105
106 struct ebt_table_info *private;
107 struct module *me;
108};
109
110#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
111 ~(__alignof__(struct _xt_align)-1))
112extern int ebt_register_table(struct net *net,
113 const struct ebt_table *table,
114 const struct nf_hook_ops *ops,
115 struct ebt_table **res);
116extern void ebt_unregister_table(struct net *net, struct ebt_table *table,
117 const struct nf_hook_ops *);
118extern unsigned int ebt_do_table(struct sk_buff *skb,
119 const struct nf_hook_state *state,
120 struct ebt_table *table);
121
122
123
124#define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
125
126#define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
127
128static inline bool ebt_invalid_target(int target)
129{
130 return (target < -NUM_STANDARD_TARGETS || target >= 0);
131}
132
133#endif
134