2 * include/net/l3mdev.h - L3 master device API
3 * Copyright (c) 2015 Cumulus Networks
4 * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
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.
11 #ifndef _NET_L3MDEV_H_
12 #define _NET_L3MDEV_H_
15 * struct l3mdev_ops - l3mdev operations
17 * @l3mdev_fib_table: Get FIB table id to use for lookups
19 * @l3mdev_get_rtable: Get cached IPv4 rtable (dst_entry) for device
21 * @l3mdev_get_saddr: Get source address for a flow
25 u32 (*l3mdev_fib_table
)(const struct net_device
*dev
);
26 struct rtable
* (*l3mdev_get_rtable
)(const struct net_device
*dev
,
27 const struct flowi4
*fl4
);
28 void (*l3mdev_get_saddr
)(struct net_device
*dev
,
32 #ifdef CONFIG_NET_L3_MASTER_DEV
34 int l3mdev_master_ifindex_rcu(struct net_device
*dev
);
35 static inline int l3mdev_master_ifindex(struct net_device
*dev
)
40 ifindex
= l3mdev_master_ifindex_rcu(dev
);
46 /* get index of an interface to use for FIB lookups. For devices
47 * enslaved to an L3 master device FIB lookups are based on the
50 static inline int l3mdev_fib_oif_rcu(struct net_device
*dev
)
52 return l3mdev_master_ifindex_rcu(dev
) ? : dev
->ifindex
;
55 static inline int l3mdev_fib_oif(struct net_device
*dev
)
60 oif
= l3mdev_fib_oif_rcu(dev
);
66 u32
l3mdev_fib_table_rcu(const struct net_device
*dev
);
67 u32
l3mdev_fib_table_by_index(struct net
*net
, int ifindex
);
68 static inline u32
l3mdev_fib_table(const struct net_device
*dev
)
73 tb_id
= l3mdev_fib_table_rcu(dev
);
79 static inline struct rtable
*l3mdev_get_rtable(const struct net_device
*dev
,
80 const struct flowi4
*fl4
)
82 if (netif_is_l3_master(dev
) && dev
->l3mdev_ops
->l3mdev_get_rtable
)
83 return dev
->l3mdev_ops
->l3mdev_get_rtable(dev
, fl4
);
88 static inline bool netif_index_is_l3_master(struct net
*net
, int ifindex
)
90 struct net_device
*dev
;
98 dev
= dev_get_by_index_rcu(net
, ifindex
);
100 rc
= netif_is_l3_master(dev
);
107 static inline void l3mdev_get_saddr(struct net
*net
, int ifindex
,
110 struct net_device
*dev
;
116 dev
= dev_get_by_index_rcu(net
, ifindex
);
117 if (dev
&& netif_is_l3_master(dev
) &&
118 dev
->l3mdev_ops
->l3mdev_get_saddr
) {
119 dev
->l3mdev_ops
->l3mdev_get_saddr(dev
, fl4
);
128 static inline int l3mdev_master_ifindex_rcu(struct net_device
*dev
)
132 static inline int l3mdev_master_ifindex(struct net_device
*dev
)
137 static inline int l3mdev_fib_oif_rcu(struct net_device
*dev
)
139 return dev
? dev
->ifindex
: 0;
141 static inline int l3mdev_fib_oif(struct net_device
*dev
)
143 return dev
? dev
->ifindex
: 0;
146 static inline u32
l3mdev_fib_table_rcu(const struct net_device
*dev
)
150 static inline u32
l3mdev_fib_table(const struct net_device
*dev
)
154 static inline u32
l3mdev_fib_table_by_index(struct net
*net
, int ifindex
)
159 static inline struct rtable
*l3mdev_get_rtable(const struct net_device
*dev
,
160 const struct flowi4
*fl4
)
165 static inline bool netif_index_is_l3_master(struct net
*net
, int ifindex
)
170 static inline void l3mdev_get_saddr(struct net
*net
, int ifindex
,
176 #endif /* _NET_L3MDEV_H_ */
This page took 0.059644 seconds and 5 git commands to generate.