l3mdev.h (9d066a252786e1a18484a6283f82614d42a9f4ac) l3mdev.h (0d240e7811c4ec1965760ee4643b5bbc9cfacbb3)
1/*
2 * include/net/l3mdev.h - L3 master device API
3 * Copyright (c) 2015 Cumulus Networks
4 * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _NET_L3MDEV_H_
12#define _NET_L3MDEV_H_
13
1/*
2 * include/net/l3mdev.h - L3 master device API
3 * Copyright (c) 2015 Cumulus Networks
4 * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _NET_L3MDEV_H_
12#define _NET_L3MDEV_H_
13
14#include <net/fib_rules.h>
15
14/**
15 * struct l3mdev_ops - l3mdev operations
16 *
17 * @l3mdev_fib_table: Get FIB table id to use for lookups
18 *
19 * @l3mdev_get_rtable: Get cached IPv4 rtable (dst_entry) for device
20 *
21 * @l3mdev_get_saddr: Get source address for a flow

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

31 /* IPv4 ops */
32 struct rtable * (*l3mdev_get_rtable)(const struct net_device *dev,
33 const struct flowi4 *fl4);
34 int (*l3mdev_get_saddr)(struct net_device *dev,
35 struct flowi4 *fl4);
36
37 /* IPv6 ops */
38 struct dst_entry * (*l3mdev_get_rt6_dst)(const struct net_device *dev,
16/**
17 * struct l3mdev_ops - l3mdev operations
18 *
19 * @l3mdev_fib_table: Get FIB table id to use for lookups
20 *
21 * @l3mdev_get_rtable: Get cached IPv4 rtable (dst_entry) for device
22 *
23 * @l3mdev_get_saddr: Get source address for a flow

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

33 /* IPv4 ops */
34 struct rtable * (*l3mdev_get_rtable)(const struct net_device *dev,
35 const struct flowi4 *fl4);
36 int (*l3mdev_get_saddr)(struct net_device *dev,
37 struct flowi4 *fl4);
38
39 /* IPv6 ops */
40 struct dst_entry * (*l3mdev_get_rt6_dst)(const struct net_device *dev,
39 const struct flowi6 *fl6);
41 struct flowi6 *fl6);
42 int (*l3mdev_get_saddr6)(struct net_device *dev,
43 const struct sock *sk,
44 struct flowi6 *fl6);
40};
41
42#ifdef CONFIG_NET_L3_MASTER_DEV
43
45};
46
47#ifdef CONFIG_NET_L3_MASTER_DEV
48
49int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
50 struct fib_lookup_arg *arg);
51
44int l3mdev_master_ifindex_rcu(const struct net_device *dev);
45static inline int l3mdev_master_ifindex(struct net_device *dev)
46{
47 int ifindex;
48
49 rcu_read_lock();
50 ifindex = l3mdev_master_ifindex_rcu(dev);
51 rcu_read_unlock();

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

129
130 rcu_read_unlock();
131
132 return rc;
133}
134
135int l3mdev_get_saddr(struct net *net, int ifindex, struct flowi4 *fl4);
136
52int l3mdev_master_ifindex_rcu(const struct net_device *dev);
53static inline int l3mdev_master_ifindex(struct net_device *dev)
54{
55 int ifindex;
56
57 rcu_read_lock();
58 ifindex = l3mdev_master_ifindex_rcu(dev);
59 rcu_read_unlock();

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

137
138 rcu_read_unlock();
139
140 return rc;
141}
142
143int l3mdev_get_saddr(struct net *net, int ifindex, struct flowi4 *fl4);
144
137struct dst_entry *l3mdev_get_rt6_dst(struct net *net, const struct flowi6 *fl6);
145struct dst_entry *l3mdev_get_rt6_dst(struct net *net, struct flowi6 *fl6);
146int l3mdev_get_saddr6(struct net *net, const struct sock *sk,
147 struct flowi6 *fl6);
138
139static inline
140struct sk_buff *l3mdev_l3_rcv(struct sk_buff *skb, u16 proto)
141{
142 struct net_device *master = NULL;
143
144 if (netif_is_l3_slave(skb->dev))
145 master = netdev_master_upper_dev_get_rcu(skb->dev);

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

215
216static inline int l3mdev_get_saddr(struct net *net, int ifindex,
217 struct flowi4 *fl4)
218{
219 return 0;
220}
221
222static inline
148
149static inline
150struct sk_buff *l3mdev_l3_rcv(struct sk_buff *skb, u16 proto)
151{
152 struct net_device *master = NULL;
153
154 if (netif_is_l3_slave(skb->dev))
155 master = netdev_master_upper_dev_get_rcu(skb->dev);

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

225
226static inline int l3mdev_get_saddr(struct net *net, int ifindex,
227 struct flowi4 *fl4)
228{
229 return 0;
230}
231
232static inline
223struct dst_entry *l3mdev_get_rt6_dst(struct net *net, const struct flowi6 *fl6)
233struct dst_entry *l3mdev_get_rt6_dst(struct net *net, struct flowi6 *fl6)
224{
225 return NULL;
226}
227
234{
235 return NULL;
236}
237
238static inline int l3mdev_get_saddr6(struct net *net, const struct sock *sk,
239 struct flowi6 *fl6)
240{
241 return 0;
242}
243
228static inline
229struct sk_buff *l3mdev_ip_rcv(struct sk_buff *skb)
230{
231 return skb;
232}
233
234static inline
235struct sk_buff *l3mdev_ip6_rcv(struct sk_buff *skb)
236{
237 return skb;
238}
244static inline
245struct sk_buff *l3mdev_ip_rcv(struct sk_buff *skb)
246{
247 return skb;
248}
249
250static inline
251struct sk_buff *l3mdev_ip6_rcv(struct sk_buff *skb)
252{
253 return skb;
254}
255
256static inline
257int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
258 struct fib_lookup_arg *arg)
259{
260 return 1;
261}
239#endif
240
241#endif /* _NET_L3MDEV_H_ */
262#endif
263
264#endif /* _NET_L3MDEV_H_ */