lwtunnel.c (81bf1c64e7fe08f956c74fe2b0f1fa6eb163bd91) lwtunnel.c (127eb7cd3c210afead788991a30950a9e36759ea)
1/*
2 * lwtunnel Infrastructure for light weight tunnels like mpls
3 *
4 * Authors: Roopa Prabhu, <roopa@cumulusnetworks.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 58 unchanged lines hidden (view full) ---

67
68 synchronize_net();
69
70 return ret;
71}
72EXPORT_SYMBOL(lwtunnel_encap_del_ops);
73
74int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
1/*
2 * lwtunnel Infrastructure for light weight tunnels like mpls
3 *
4 * Authors: Roopa Prabhu, <roopa@cumulusnetworks.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 58 unchanged lines hidden (view full) ---

67
68 synchronize_net();
69
70 return ret;
71}
72EXPORT_SYMBOL(lwtunnel_encap_del_ops);
73
74int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
75 struct nlattr *encap, struct lwtunnel_state **lws)
75 struct nlattr *encap, unsigned int family,
76 const void *cfg, struct lwtunnel_state **lws)
76{
77 const struct lwtunnel_encap_ops *ops;
78 int ret = -EINVAL;
79
80 if (encap_type == LWTUNNEL_ENCAP_NONE ||
81 encap_type > LWTUNNEL_ENCAP_MAX)
82 return ret;
83
84 ret = -EOPNOTSUPP;
85 rcu_read_lock();
86 ops = rcu_dereference(lwtun_encaps[encap_type]);
87 if (likely(ops && ops->build_state))
77{
78 const struct lwtunnel_encap_ops *ops;
79 int ret = -EINVAL;
80
81 if (encap_type == LWTUNNEL_ENCAP_NONE ||
82 encap_type > LWTUNNEL_ENCAP_MAX)
83 return ret;
84
85 ret = -EOPNOTSUPP;
86 rcu_read_lock();
87 ops = rcu_dereference(lwtun_encaps[encap_type]);
88 if (likely(ops && ops->build_state))
88 ret = ops->build_state(dev, encap, lws);
89 ret = ops->build_state(dev, encap, family, cfg, lws);
89 rcu_read_unlock();
90
91 return ret;
92}
93EXPORT_SYMBOL(lwtunnel_build_state);
94
95int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate)
96{

--- 77 unchanged lines hidden (view full) ---

174 if (likely(ops && ops->cmp_encap))
175 ret = ops->cmp_encap(a, b);
176 rcu_read_unlock();
177
178 return ret;
179}
180EXPORT_SYMBOL(lwtunnel_cmp_encap);
181
90 rcu_read_unlock();
91
92 return ret;
93}
94EXPORT_SYMBOL(lwtunnel_build_state);
95
96int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate)
97{

--- 77 unchanged lines hidden (view full) ---

175 if (likely(ops && ops->cmp_encap))
176 ret = ops->cmp_encap(a, b);
177 rcu_read_unlock();
178
179 return ret;
180}
181EXPORT_SYMBOL(lwtunnel_cmp_encap);
182
182int __lwtunnel_output(struct sock *sk, struct sk_buff *skb,
183 struct lwtunnel_state *lwtstate)
183int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
184{
184{
185 struct dst_entry *dst = skb_dst(skb);
185 const struct lwtunnel_encap_ops *ops;
186 const struct lwtunnel_encap_ops *ops;
187 struct lwtunnel_state *lwtstate;
186 int ret = -EINVAL;
187
188 int ret = -EINVAL;
189
188 if (!lwtstate)
190 if (!dst)
189 goto drop;
191 goto drop;
192 lwtstate = dst->lwtstate;
190
191 if (lwtstate->type == LWTUNNEL_ENCAP_NONE ||
192 lwtstate->type > LWTUNNEL_ENCAP_MAX)
193 return 0;
194
195 ret = -EOPNOTSUPP;
196 rcu_read_lock();
197 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);

--- 6 unchanged lines hidden (view full) ---

204
205 return ret;
206
207drop:
208 kfree_skb(skb);
209
210 return ret;
211}
193
194 if (lwtstate->type == LWTUNNEL_ENCAP_NONE ||
195 lwtstate->type > LWTUNNEL_ENCAP_MAX)
196 return 0;
197
198 ret = -EOPNOTSUPP;
199 rcu_read_lock();
200 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);

--- 6 unchanged lines hidden (view full) ---

207
208 return ret;
209
210drop:
211 kfree_skb(skb);
212
213 return ret;
214}
212
213int lwtunnel_output6(struct sock *sk, struct sk_buff *skb)
214{
215 struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
216 struct lwtunnel_state *lwtstate = NULL;
217
218 if (rt) {
219 lwtstate = rt->rt6i_lwtstate;
220 skb->dev = rt->dst.dev;
221 }
222
223 skb->protocol = htons(ETH_P_IPV6);
224
225 return __lwtunnel_output(sk, skb, lwtstate);
226}
227EXPORT_SYMBOL(lwtunnel_output6);
228
229int lwtunnel_output(struct sock *sk, struct sk_buff *skb)
230{
231 struct rtable *rt = (struct rtable *)skb_dst(skb);
232 struct lwtunnel_state *lwtstate = NULL;
233
234 if (rt) {
235 lwtstate = rt->rt_lwtstate;
236 skb->dev = rt->dst.dev;
237 }
238
239 skb->protocol = htons(ETH_P_IP);
240
241 return __lwtunnel_output(sk, skb, lwtstate);
242}
243EXPORT_SYMBOL(lwtunnel_output);
244
215EXPORT_SYMBOL(lwtunnel_output);
216
245int __lwtunnel_input(struct sk_buff *skb,
246 struct lwtunnel_state *lwtstate)
217int lwtunnel_input(struct sk_buff *skb)
247{
218{
219 struct dst_entry *dst = skb_dst(skb);
248 const struct lwtunnel_encap_ops *ops;
220 const struct lwtunnel_encap_ops *ops;
221 struct lwtunnel_state *lwtstate;
249 int ret = -EINVAL;
250
222 int ret = -EINVAL;
223
251 if (!lwtstate)
224 if (!dst)
252 goto drop;
225 goto drop;
226 lwtstate = dst->lwtstate;
253
254 if (lwtstate->type == LWTUNNEL_ENCAP_NONE ||
255 lwtstate->type > LWTUNNEL_ENCAP_MAX)
256 return 0;
257
258 ret = -EOPNOTSUPP;
259 rcu_read_lock();
260 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);

--- 6 unchanged lines hidden (view full) ---

267
268 return ret;
269
270drop:
271 kfree_skb(skb);
272
273 return ret;
274}
227
228 if (lwtstate->type == LWTUNNEL_ENCAP_NONE ||
229 lwtstate->type > LWTUNNEL_ENCAP_MAX)
230 return 0;
231
232 ret = -EOPNOTSUPP;
233 rcu_read_lock();
234 ops = rcu_dereference(lwtun_encaps[lwtstate->type]);

--- 6 unchanged lines hidden (view full) ---

241
242 return ret;
243
244drop:
245 kfree_skb(skb);
246
247 return ret;
248}
275
276int lwtunnel_input6(struct sk_buff *skb)
277{
278 struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
279 struct lwtunnel_state *lwtstate = NULL;
280
281 if (rt)
282 lwtstate = rt->rt6i_lwtstate;
283
284 return __lwtunnel_input(skb, lwtstate);
285}
286EXPORT_SYMBOL(lwtunnel_input6);
287
288int lwtunnel_input(struct sk_buff *skb)
289{
290 struct rtable *rt = (struct rtable *)skb_dst(skb);
291 struct lwtunnel_state *lwtstate = NULL;
292
293 if (rt)
294 lwtstate = rt->rt_lwtstate;
295
296 return __lwtunnel_input(skb, lwtstate);
297}
298EXPORT_SYMBOL(lwtunnel_input);
249EXPORT_SYMBOL(lwtunnel_input);