Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 347e3b28 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

switchdev: remove FIB offload infrastructure



Since this is now taken care of by FIB notifier, remove the code, with
all unused dependencies.

Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 936bd486
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -243,7 +243,6 @@ int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
		   struct netlink_callback *cb);
int fib_table_flush(struct net *net, struct fib_table *table);
struct fib_table *fib_trie_unmerge(struct fib_table *main_tb);
void fib_table_flush_external(struct fib_table *table);
void fib_free_table(struct fib_table *tb);

#ifndef CONFIG_IP_MULTIPLE_TABLES
@@ -356,7 +355,6 @@ static inline int fib_num_tclassid_users(struct net *net)
}
#endif
int fib_unmerge(struct net *net);
void fib_flush_external(struct net *net);

/* Exported by fib_semantics.c */
int ip_fib_check_default(__be32 gw, struct net_device *dev);
+0 −40
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ struct switchdev_attr {
enum switchdev_obj_id {
	SWITCHDEV_OBJ_ID_UNDEFINED,
	SWITCHDEV_OBJ_ID_PORT_VLAN,
	SWITCHDEV_OBJ_ID_IPV4_FIB,
	SWITCHDEV_OBJ_ID_PORT_FDB,
	SWITCHDEV_OBJ_ID_PORT_MDB,
};
@@ -92,21 +91,6 @@ struct switchdev_obj_port_vlan {
#define SWITCHDEV_OBJ_PORT_VLAN(obj) \
	container_of(obj, struct switchdev_obj_port_vlan, obj)

/* SWITCHDEV_OBJ_ID_IPV4_FIB */
struct switchdev_obj_ipv4_fib {
	struct switchdev_obj obj;
	u32 dst;
	int dst_len;
	struct fib_info *fi;
	u8 tos;
	u8 type;
	u32 nlflags;
	u32 tb_id;
};

#define SWITCHDEV_OBJ_IPV4_FIB(obj) \
	container_of(obj, struct switchdev_obj_ipv4_fib, obj)

/* SWITCHDEV_OBJ_ID_PORT_FDB */
struct switchdev_obj_port_fdb {
	struct switchdev_obj obj;
@@ -209,11 +193,6 @@ int switchdev_port_bridge_setlink(struct net_device *dev,
				  struct nlmsghdr *nlh, u16 flags);
int switchdev_port_bridge_dellink(struct net_device *dev,
				  struct nlmsghdr *nlh, u16 flags);
int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
			   u8 tos, u8 type, u32 nlflags, u32 tb_id);
int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
			   u8 tos, u8 type, u32 tb_id);
void switchdev_fib_ipv4_abort(struct fib_info *fi);
int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
			   struct net_device *dev, const unsigned char *addr,
			   u16 vid, u16 nlm_flags);
@@ -304,25 +283,6 @@ static inline int switchdev_port_bridge_dellink(struct net_device *dev,
	return -EOPNOTSUPP;
}

static inline int switchdev_fib_ipv4_add(u32 dst, int dst_len,
					 struct fib_info *fi,
					 u8 tos, u8 type,
					 u32 nlflags, u32 tb_id)
{
	return 0;
}

static inline int switchdev_fib_ipv4_del(u32 dst, int dst_len,
					 struct fib_info *fi,
					 u8 tos, u8 type, u32 tb_id)
{
	return 0;
}

static inline void switchdev_fib_ipv4_abort(struct fib_info *fi)
{
}

static inline int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
					 struct net_device *dev,
					 const unsigned char *addr,
+0 −13
Original line number Diff line number Diff line
@@ -189,19 +189,6 @@ static void fib_flush(struct net *net)
		rt_cache_flush(net);
}

void fib_flush_external(struct net *net)
{
	struct fib_table *tb;
	struct hlist_head *head;
	unsigned int h;

	for (h = 0; h < FIB_TABLE_HASHSZ; h++) {
		head = &net->ipv4.fib_table_hash[h];
		hlist_for_each_entry(tb, head, tb_hlist)
			fib_table_flush_external(tb);
	}
}

/*
 * Find address type as if only "dev" was present in the system. If
 * on_dev is NULL then all interfaces are taken into consideration.
+0 −2
Original line number Diff line number Diff line
@@ -228,7 +228,6 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
	rule4->tos = frh->tos;

	net->ipv4.fib_has_custom_rules = true;
	fib_flush_external(rule->fr_net);
	call_fib_rule_notifiers(net, FIB_EVENT_RULE_ADD);

	err = 0;
@@ -251,7 +250,6 @@ static int fib4_rule_delete(struct fib_rule *rule)
		net->ipv4.fib_num_tclassid_users--;
#endif
	net->ipv4.fib_has_custom_rules = true;
	fib_flush_external(rule->fr_net);
	call_fib_rule_notifiers(net, FIB_EVENT_RULE_DEL);
errout:
	return err;
+1 −103
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@
#include <net/tcp.h>
#include <net/sock.h>
#include <net/ip_fib.h>
#include <net/switchdev.h>
#include <trace/events/fib.h>
#include "fib_lookup.h"

@@ -1215,17 +1214,6 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
			new_fa->tb_id = tb->tb_id;
			new_fa->fa_default = -1;

			err = switchdev_fib_ipv4_add(key, plen, fi,
						     new_fa->fa_tos,
						     cfg->fc_type,
						     cfg->fc_nlflags,
						     tb->tb_id);
			if (err) {
				switchdev_fib_ipv4_abort(fi);
				kmem_cache_free(fn_alias_kmem, new_fa);
				goto out;
			}

			hlist_replace_rcu(&fa->fa_list, &new_fa->fa_list);

			alias_free_mem_rcu(fa);
@@ -1273,18 +1261,10 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
	new_fa->tb_id = tb->tb_id;
	new_fa->fa_default = -1;

	/* (Optionally) offload fib entry to switch hardware. */
	err = switchdev_fib_ipv4_add(key, plen, fi, tos, cfg->fc_type,
				     cfg->fc_nlflags, tb->tb_id);
	if (err) {
		switchdev_fib_ipv4_abort(fi);
		goto out_free_new_fa;
	}

	/* Insert new entry to the list. */
	err = fib_insert_alias(t, tp, l, new_fa, fa, key);
	if (err)
		goto out_sw_fib_del;
		goto out_free_new_fa;

	if (!plen)
		tb->tb_num_default++;
@@ -1297,8 +1277,6 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
succeeded:
	return 0;

out_sw_fib_del:
	switchdev_fib_ipv4_del(key, plen, fi, tos, cfg->fc_type, tb->tb_id);
out_free_new_fa:
	kmem_cache_free(fn_alias_kmem, new_fa);
out:
@@ -1591,9 +1569,6 @@ int fib_table_delete(struct net *net, struct fib_table *tb,
	if (!fa_to_delete)
		return -ESRCH;

	switchdev_fib_ipv4_del(key, plen, fa_to_delete->fa_info, tos,
			       cfg->fc_type, tb->tb_id);

	call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_DEL, key, plen,
				 fa_to_delete->fa_info, tos, cfg->fc_type,
				 tb->tb_id, 0);
@@ -1785,80 +1760,6 @@ struct fib_table *fib_trie_unmerge(struct fib_table *oldtb)
	return NULL;
}

/* Caller must hold RTNL */
void fib_table_flush_external(struct fib_table *tb)
{
	struct trie *t = (struct trie *)tb->tb_data;
	struct key_vector *pn = t->kv;
	unsigned long cindex = 1;
	struct hlist_node *tmp;
	struct fib_alias *fa;

	/* walk trie in reverse order */
	for (;;) {
		unsigned char slen = 0;
		struct key_vector *n;

		if (!(cindex--)) {
			t_key pkey = pn->key;

			/* cannot resize the trie vector */
			if (IS_TRIE(pn))
				break;

			/* resize completed node */
			pn = resize(t, pn);
			cindex = get_index(pkey, pn);

			continue;
		}

		/* grab the next available node */
		n = get_child(pn, cindex);
		if (!n)
			continue;

		if (IS_TNODE(n)) {
			/* record pn and cindex for leaf walking */
			pn = n;
			cindex = 1ul << n->bits;

			continue;
		}

		hlist_for_each_entry_safe(fa, tmp, &n->leaf, fa_list) {
			struct fib_info *fi = fa->fa_info;

			/* if alias was cloned to local then we just
			 * need to remove the local copy from main
			 */
			if (tb->tb_id != fa->tb_id) {
				hlist_del_rcu(&fa->fa_list);
				alias_free_mem_rcu(fa);
				continue;
			}

			/* record local slen */
			slen = fa->fa_slen;

			if (!fi || !(fi->fib_flags & RTNH_F_OFFLOAD))
				continue;

			switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
					       fi, fa->fa_tos, fa->fa_type,
					       tb->tb_id);
		}

		/* update leaf slen */
		n->slen = slen;

		if (hlist_empty(&n->leaf)) {
			put_child_root(pn, n->key, NULL);
			node_free(n);
		}
	}
}

/* Caller must hold RTNL. */
int fib_table_flush(struct net *net, struct fib_table *tb)
{
@@ -1909,9 +1810,6 @@ int fib_table_flush(struct net *net, struct fib_table *tb)
				continue;
			}

			switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
					       fi, fa->fa_tos, fa->fa_type,
					       tb->tb_id);
			call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_DEL,
						 n->key,
						 KEYLENGTH - fa->fa_slen,
Loading