7
7
8
8
#include <net/sch_generic.h>
9
9
#include <net/pkt_sched.h>
10
+ #include <net/net_namespace.h>
11
+ #include <net/netns/generic.h>
10
12
11
13
struct tcf_common {
12
14
struct hlist_node tcfc_head ;
@@ -87,31 +89,65 @@ struct tc_action {
87
89
__u32 type ; /* for backward compat(TCA_OLD_COMPAT) */
88
90
__u32 order ;
89
91
struct list_head list ;
92
+ struct tcf_hashinfo * hinfo ;
90
93
};
91
94
92
95
struct tc_action_ops {
93
96
struct list_head head ;
94
- struct tcf_hashinfo * hinfo ;
95
97
char kind [IFNAMSIZ ];
96
98
__u32 type ; /* TBD to match kind */
97
99
struct module * owner ;
98
100
int (* act )(struct sk_buff * , const struct tc_action * , struct tcf_result * );
99
101
int (* dump )(struct sk_buff * , struct tc_action * , int , int );
100
102
void (* cleanup )(struct tc_action * , int bind );
101
- int (* lookup )(struct tc_action * , u32 );
103
+ int (* lookup )(struct net * , struct tc_action * , u32 );
102
104
int (* init )(struct net * net , struct nlattr * nla ,
103
105
struct nlattr * est , struct tc_action * act , int ovr ,
104
106
int bind );
105
- int (* walk )(struct sk_buff * , struct netlink_callback * , int , struct tc_action * );
107
+ int (* walk )(struct net * , struct sk_buff * ,
108
+ struct netlink_callback * , int , struct tc_action * );
109
+ };
110
+
111
+ struct tc_action_net {
112
+ struct tcf_hashinfo * hinfo ;
113
+ const struct tc_action_ops * ops ;
106
114
};
107
115
108
- int tcf_hash_search (struct tc_action * a , u32 index );
109
- u32 tcf_hash_new_index (struct tcf_hashinfo * hinfo );
110
- int tcf_hash_check (u32 index , struct tc_action * a , int bind );
111
- int tcf_hash_create (u32 index , struct nlattr * est , struct tc_action * a ,
112
- int size , int bind , bool cpustats );
116
+ static inline
117
+ int tc_action_net_init (struct tc_action_net * tn , const struct tc_action_ops * ops ,
118
+ unsigned int mask )
119
+ {
120
+ int err = 0 ;
121
+
122
+ tn -> hinfo = kmalloc (sizeof (* tn -> hinfo ), GFP_KERNEL );
123
+ if (!tn -> hinfo )
124
+ return - ENOMEM ;
125
+ tn -> ops = ops ;
126
+ err = tcf_hashinfo_init (tn -> hinfo , mask );
127
+ if (err )
128
+ kfree (tn -> hinfo );
129
+ return err ;
130
+ }
131
+
132
+ void tcf_hashinfo_destroy (const struct tc_action_ops * ops ,
133
+ struct tcf_hashinfo * hinfo );
134
+
135
+ static inline void tc_action_net_exit (struct tc_action_net * tn )
136
+ {
137
+ tcf_hashinfo_destroy (tn -> ops , tn -> hinfo );
138
+ }
139
+
140
+ int tcf_generic_walker (struct tc_action_net * tn , struct sk_buff * skb ,
141
+ struct netlink_callback * cb , int type ,
142
+ struct tc_action * a );
143
+ int tcf_hash_search (struct tc_action_net * tn , struct tc_action * a , u32 index );
144
+ u32 tcf_hash_new_index (struct tc_action_net * tn );
145
+ int tcf_hash_check (struct tc_action_net * tn , u32 index , struct tc_action * a ,
146
+ int bind );
147
+ int tcf_hash_create (struct tc_action_net * tn , u32 index , struct nlattr * est ,
148
+ struct tc_action * a , int size , int bind , bool cpustats );
113
149
void tcf_hash_cleanup (struct tc_action * a , struct nlattr * est );
114
- void tcf_hash_insert (struct tc_action * a );
150
+ void tcf_hash_insert (struct tc_action_net * tn , struct tc_action * a );
115
151
116
152
int __tcf_hash_release (struct tc_action * a , bool bind , bool strict );
117
153
@@ -120,8 +156,8 @@ static inline int tcf_hash_release(struct tc_action *a, bool bind)
120
156
return __tcf_hash_release (a , bind , false);
121
157
}
122
158
123
- int tcf_register_action (struct tc_action_ops * a , unsigned int mask );
124
- int tcf_unregister_action (struct tc_action_ops * a );
159
+ int tcf_register_action (struct tc_action_ops * a , struct pernet_operations * ops );
160
+ int tcf_unregister_action (struct tc_action_ops * a , struct pernet_operations * ops );
125
161
int tcf_action_destroy (struct list_head * actions , int bind );
126
162
int tcf_action_exec (struct sk_buff * skb , const struct list_head * actions ,
127
163
struct tcf_result * res );
0 commit comments