include/net/l3mdev.h

Source file repositories/reference/linux-study-clean/include/net/l3mdev.h

File Facts

System
Linux kernel
Corpus path
include/net/l3mdev.h
Extension
.h
Size
7765 bytes
Lines
365
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct l3mdev_ops {
	u32		(*l3mdev_fib_table)(const struct net_device *dev);
	struct sk_buff * (*l3mdev_l3_rcv)(struct net_device *dev,
					  struct sk_buff *skb, u16 proto);
	struct sk_buff * (*l3mdev_l3_out)(struct net_device *dev,
					  struct sock *sk, struct sk_buff *skb,
					  u16 proto);

	/* IPv6 ops */
	struct dst_entry * (*l3mdev_link_scope_lookup)(const struct net_device *dev,
						 struct flowi6 *fl6);
};

#ifdef CONFIG_NET_L3_MASTER_DEV

int l3mdev_table_lookup_register(enum l3mdev_type l3type,
				 lookup_by_table_id_t fn);

void l3mdev_table_lookup_unregister(enum l3mdev_type l3type,
				    lookup_by_table_id_t fn);

int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net,
				      u32 table_id);

int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
			  struct fib_lookup_arg *arg);

static inline
bool l3mdev_fib_rule_iif_match(const struct flowi *fl, int iifindex)
{
	return !(fl->flowi_flags & FLOWI_FLAG_L3MDEV_OIF) &&
	       fl->flowi_l3mdev == iifindex;
}

static inline
bool l3mdev_fib_rule_oif_match(const struct flowi *fl, int oifindex)
{
	return fl->flowi_flags & FLOWI_FLAG_L3MDEV_OIF &&
	       fl->flowi_l3mdev == oifindex;
}

void l3mdev_update_flow(struct net *net, struct flowi *fl);

int l3mdev_master_ifindex_rcu(const struct net_device *dev);
static inline int l3mdev_master_ifindex(struct net_device *dev)
{
	int ifindex;

	rcu_read_lock();
	ifindex = l3mdev_master_ifindex_rcu(dev);
	rcu_read_unlock();

	return ifindex;
}

static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
{
	struct net_device *dev;
	int rc = 0;

	if (ifindex) {
		rcu_read_lock();

		dev = dev_get_by_index_rcu(net, ifindex);
		if (dev)
			rc = l3mdev_master_ifindex_rcu(dev);

		rcu_read_unlock();
	}

	return rc;
}

static inline
struct net_device *l3mdev_master_dev_rcu(const struct net_device *_dev)
{
	/* netdev_master_upper_dev_get_rcu calls
	 * list_first_or_null_rcu to walk the upper dev list.
	 * list_first_or_null_rcu does not handle a const arg. We aren't
	 * making changes, just want the master device from that list so
	 * typecast to remove the const
	 */
	struct net_device *dev = (struct net_device *)_dev;
	struct net_device *master;

	if (!dev)
		return NULL;

	if (netif_is_l3_master(dev))
		master = dev;

Annotation

Implementation Notes