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