^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * include/net/l3mdev.h - L3 master device API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2015 Cumulus Networks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2015 David Ahern <dsa@cumulusnetworks.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef _NET_L3MDEV_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define _NET_L3MDEV_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <net/dst.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <net/fib_rules.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) enum l3mdev_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) L3MDEV_TYPE_UNSPEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) L3MDEV_TYPE_VRF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) __L3MDEV_TYPE_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define L3MDEV_TYPE_MAX (__L3MDEV_TYPE_MAX - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) typedef int (*lookup_by_table_id_t)(struct net *net, u32 table_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * struct l3mdev_ops - l3mdev operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * @l3mdev_fib_table: Get FIB table id to use for lookups
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @l3mdev_l3_rcv: Hook in L3 receive path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @l3mdev_l3_out: Hook in L3 output path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @l3mdev_link_scope_lookup: IPv6 lookup for linklocal and mcast destinations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct l3mdev_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 (*l3mdev_fib_table)(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct sk_buff * (*l3mdev_l3_rcv)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct sk_buff *skb, u16 proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct sk_buff * (*l3mdev_l3_out)(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct sock *sk, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) u16 proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* IPv6 ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct dst_entry * (*l3mdev_link_scope_lookup)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct flowi6 *fl6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #ifdef CONFIG_NET_L3_MASTER_DEV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int l3mdev_table_lookup_register(enum l3mdev_type l3type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) lookup_by_table_id_t fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void l3mdev_table_lookup_unregister(enum l3mdev_type l3type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) lookup_by_table_id_t fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u32 table_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct fib_lookup_arg *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) void l3mdev_update_flow(struct net *net, struct flowi *fl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int l3mdev_master_ifindex_rcu(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static inline int l3mdev_master_ifindex(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ifindex = l3mdev_master_ifindex_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (likely(ifindex)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) dev = dev_get_by_index_rcu(net, ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) rc = l3mdev_master_ifindex_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct net_device *l3mdev_master_dev_rcu(const struct net_device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* netdev_master_upper_dev_get_rcu calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * list_first_or_null_rcu to walk the upper dev list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * list_first_or_null_rcu does not handle a const arg. We aren't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * making changes, just want the master device from that list so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * typecast to remove the const
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct net_device *dev = (struct net_device *)_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct net_device *master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (netif_is_l3_master(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) master = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) else if (netif_is_l3_slave(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) master = netdev_master_upper_dev_get_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) master = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int l3mdev_master_upper_ifindex_by_index_rcu(struct net *net, int ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int l3mdev_master_upper_ifindex_by_index(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ifindex = l3mdev_master_upper_ifindex_by_index_rcu(net, ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) u32 l3mdev_fib_table_rcu(const struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u32 l3mdev_fib_table_by_index(struct net *net, int ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static inline u32 l3mdev_fib_table(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) u32 tb_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) tb_id = l3mdev_fib_table_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return tb_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static inline bool netif_index_is_l3_master(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) bool rc = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (ifindex == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) dev = dev_get_by_index_rcu(net, ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) rc = netif_is_l3_master(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct dst_entry *l3mdev_link_scope_lookup(struct net *net, struct flowi6 *fl6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct sk_buff *l3mdev_l3_rcv(struct sk_buff *skb, u16 proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct net_device *master = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (netif_is_l3_slave(skb->dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) master = netdev_master_upper_dev_get_rcu(skb->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) else if (netif_is_l3_master(skb->dev) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) netif_has_l3_rx_handler(skb->dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) master = skb->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (master && master->l3mdev_ops->l3mdev_l3_rcv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) skb = master->l3mdev_ops->l3mdev_l3_rcv(master, skb, proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct sk_buff *l3mdev_ip_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return l3mdev_l3_rcv(skb, AF_INET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct sk_buff *l3mdev_ip6_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return l3mdev_l3_rcv(skb, AF_INET6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct sk_buff *l3mdev_l3_out(struct sock *sk, struct sk_buff *skb, u16 proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct net_device *dev = skb_dst(skb)->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (netif_is_l3_slave(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct net_device *master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) master = netdev_master_upper_dev_get_rcu(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (master && master->l3mdev_ops->l3mdev_l3_out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) skb = master->l3mdev_ops->l3mdev_l3_out(master, sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) skb, proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct sk_buff *l3mdev_ip_out(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return l3mdev_l3_out(sk, skb, AF_INET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct sk_buff *l3mdev_ip6_out(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return l3mdev_l3_out(sk, skb, AF_INET6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static inline int l3mdev_master_ifindex_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline int l3mdev_master_ifindex(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int l3mdev_master_upper_ifindex_by_index_rcu(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) int l3mdev_master_upper_ifindex_by_index(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct net_device *l3mdev_master_dev_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static inline u32 l3mdev_fib_table_rcu(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static inline u32 l3mdev_fib_table(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline u32 l3mdev_fib_table_by_index(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static inline bool netif_index_is_l3_master(struct net *net, int ifindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct dst_entry *l3mdev_link_scope_lookup(struct net *net, struct flowi6 *fl6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct sk_buff *l3mdev_ip_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct sk_buff *l3mdev_ip6_rcv(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct sk_buff *l3mdev_ip_out(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct sk_buff *l3mdev_ip6_out(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int l3mdev_table_lookup_register(enum l3mdev_type l3type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) lookup_by_table_id_t fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void l3mdev_table_lookup_unregister(enum l3mdev_type l3type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) lookup_by_table_id_t fn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) u32 table_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) struct fib_lookup_arg *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) void l3mdev_update_flow(struct net *net, struct flowi *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) #endif /* _NET_L3MDEV_H_ */