Commit 68e2c376 authored by David S. Miller's avatar David S. Miller

Merge branch 'hsr-several-code-cleanup-for-hsr-module'

Taehee Yoo says:

====================
hsr: several code cleanup for hsr module

This patchset is to clean up hsr module code.

1. The first patch is to use debugfs_remove_recursive().
If it uses debugfs_remove_recursive() instead of debugfs_remove(),
hsr_priv() doesn't need to have "node_tbl_file" pointer variable.

2. The second patch is to use extack error message.
If HSR uses the extack instead of netdev_info(), users can get
error messages immediately without any checking the kernel message.

3. The third patch is to use netdev_err() instead of WARN_ONCE().
When a packet is being sent, hsr_addr_subst_dest() is called and
it tries to find the node with the ethernet destination address.
If it couldn't find a node, it warns with WARN_ONCE().
But, using WARN_ONCE() is a little bit overdoing.
So, in this patch, netdev_err() is used instead.

4. The fourth patch is to remove unnecessary rcu_read_{lock/unlock}().
There are some rcu_read_{lock/unlock}() in hsr module and some of
them are unnecessary. In this patch,
these unnecessary rcu_read_{lock/unlock}() will be removed.

5. The fifth patch is to use upper/lower device infrastructure.
netdev_upper_dev_link() is useful to manage lower/upper interfaces.
And this function internally validates looping, maximum depth.
If hsr module uses upper/lower device infrastructure,
it can prevent these above problems.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 892e0915 e0a4b997
...@@ -113,7 +113,6 @@ void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev) ...@@ -113,7 +113,6 @@ void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
priv->node_tbl_root = NULL; priv->node_tbl_root = NULL;
return; return;
} }
priv->node_tbl_file = de;
} }
/* hsr_debugfs_term - Tear down debugfs intrastructure /* hsr_debugfs_term - Tear down debugfs intrastructure
...@@ -125,9 +124,7 @@ void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev) ...@@ -125,9 +124,7 @@ void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
void void
hsr_debugfs_term(struct hsr_priv *priv) hsr_debugfs_term(struct hsr_priv *priv)
{ {
debugfs_remove(priv->node_tbl_file); debugfs_remove_recursive(priv->node_tbl_root);
priv->node_tbl_file = NULL;
debugfs_remove(priv->node_tbl_root);
priv->node_tbl_root = NULL; priv->node_tbl_root = NULL;
} }
......
...@@ -57,24 +57,19 @@ static void hsr_set_operstate(struct hsr_port *master, bool has_carrier) ...@@ -57,24 +57,19 @@ static void hsr_set_operstate(struct hsr_port *master, bool has_carrier)
static bool hsr_check_carrier(struct hsr_port *master) static bool hsr_check_carrier(struct hsr_port *master)
{ {
struct hsr_port *port; struct hsr_port *port;
bool has_carrier;
has_carrier = false; ASSERT_RTNL();
rcu_read_lock(); hsr_for_each_port(master->hsr, port) {
hsr_for_each_port(master->hsr, port)
if (port->type != HSR_PT_MASTER && is_slave_up(port->dev)) { if (port->type != HSR_PT_MASTER && is_slave_up(port->dev)) {
has_carrier = true; netif_carrier_on(master->dev);
break; return true;
}
} }
rcu_read_unlock();
if (has_carrier)
netif_carrier_on(master->dev);
else
netif_carrier_off(master->dev); netif_carrier_off(master->dev);
return has_carrier; return false;
} }
static void hsr_check_announce(struct net_device *hsr_dev, static void hsr_check_announce(struct net_device *hsr_dev,
...@@ -118,11 +113,9 @@ int hsr_get_max_mtu(struct hsr_priv *hsr) ...@@ -118,11 +113,9 @@ int hsr_get_max_mtu(struct hsr_priv *hsr)
struct hsr_port *port; struct hsr_port *port;
mtu_max = ETH_DATA_LEN; mtu_max = ETH_DATA_LEN;
rcu_read_lock();
hsr_for_each_port(hsr, port) hsr_for_each_port(hsr, port)
if (port->type != HSR_PT_MASTER) if (port->type != HSR_PT_MASTER)
mtu_max = min(port->dev->mtu, mtu_max); mtu_max = min(port->dev->mtu, mtu_max);
rcu_read_unlock();
if (mtu_max < HSR_HLEN) if (mtu_max < HSR_HLEN)
return 0; return 0;
...@@ -157,7 +150,6 @@ static int hsr_dev_open(struct net_device *dev) ...@@ -157,7 +150,6 @@ static int hsr_dev_open(struct net_device *dev)
hsr = netdev_priv(dev); hsr = netdev_priv(dev);
designation = '\0'; designation = '\0';
rcu_read_lock();
hsr_for_each_port(hsr, port) { hsr_for_each_port(hsr, port) {
if (port->type == HSR_PT_MASTER) if (port->type == HSR_PT_MASTER)
continue; continue;
...@@ -175,7 +167,6 @@ static int hsr_dev_open(struct net_device *dev) ...@@ -175,7 +167,6 @@ static int hsr_dev_open(struct net_device *dev)
netdev_warn(dev, "Slave %c (%s) is not up; please bring it up to get a fully working HSR network\n", netdev_warn(dev, "Slave %c (%s) is not up; please bring it up to get a fully working HSR network\n",
designation, port->dev->name); designation, port->dev->name);
} }
rcu_read_unlock();
if (designation == '\0') if (designation == '\0')
netdev_warn(dev, "No slave devices configured\n"); netdev_warn(dev, "No slave devices configured\n");
...@@ -350,22 +341,33 @@ static void hsr_announce(struct timer_list *t) ...@@ -350,22 +341,33 @@ static void hsr_announce(struct timer_list *t)
rcu_read_unlock(); rcu_read_unlock();
} }
static void hsr_del_ports(struct hsr_priv *hsr)
{
struct hsr_port *port;
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
if (port)
hsr_del_port(port);
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
if (port)
hsr_del_port(port);
port = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
if (port)
hsr_del_port(port);
}
/* This has to be called after all the readers are gone. /* This has to be called after all the readers are gone.
* Otherwise we would have to check the return value of * Otherwise we would have to check the return value of
* hsr_port_get_hsr(). * hsr_port_get_hsr().
*/ */
static void hsr_dev_destroy(struct net_device *hsr_dev) static void hsr_dev_destroy(struct net_device *hsr_dev)
{ {
struct hsr_priv *hsr; struct hsr_priv *hsr = netdev_priv(hsr_dev);
struct hsr_port *port;
struct hsr_port *tmp;
hsr = netdev_priv(hsr_dev);
hsr_debugfs_term(hsr); hsr_debugfs_term(hsr);
hsr_del_ports(hsr);
list_for_each_entry_safe(port, tmp, &hsr->ports, port_list)
hsr_del_port(port);
del_timer_sync(&hsr->prune_timer); del_timer_sync(&hsr->prune_timer);
del_timer_sync(&hsr->announce_timer); del_timer_sync(&hsr->announce_timer);
...@@ -431,11 +433,10 @@ static const unsigned char def_multicast_addr[ETH_ALEN] __aligned(2) = { ...@@ -431,11 +433,10 @@ static const unsigned char def_multicast_addr[ETH_ALEN] __aligned(2) = {
}; };
int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
unsigned char multicast_spec, u8 protocol_version) unsigned char multicast_spec, u8 protocol_version,
struct netlink_ext_ack *extack)
{ {
struct hsr_priv *hsr; struct hsr_priv *hsr;
struct hsr_port *port;
struct hsr_port *tmp;
int res; int res;
hsr = netdev_priv(hsr_dev); hsr = netdev_priv(hsr_dev);
...@@ -478,7 +479,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], ...@@ -478,7 +479,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
/* Make sure the 1st call to netif_carrier_on() gets through */ /* Make sure the 1st call to netif_carrier_on() gets through */
netif_carrier_off(hsr_dev); netif_carrier_off(hsr_dev);
res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER); res = hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER, extack);
if (res) if (res)
goto err_add_master; goto err_add_master;
...@@ -486,11 +487,11 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], ...@@ -486,11 +487,11 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
if (res) if (res)
goto err_unregister; goto err_unregister;
res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A); res = hsr_add_port(hsr, slave[0], HSR_PT_SLAVE_A, extack);
if (res) if (res)
goto err_add_slaves; goto err_add_slaves;
res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B); res = hsr_add_port(hsr, slave[1], HSR_PT_SLAVE_B, extack);
if (res) if (res)
goto err_add_slaves; goto err_add_slaves;
...@@ -502,8 +503,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], ...@@ -502,8 +503,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
err_add_slaves: err_add_slaves:
unregister_netdevice(hsr_dev); unregister_netdevice(hsr_dev);
err_unregister: err_unregister:
list_for_each_entry_safe(port, tmp, &hsr->ports, port_list) hsr_del_ports(hsr);
hsr_del_port(port);
err_add_master: err_add_master:
hsr_del_self_node(hsr); hsr_del_self_node(hsr);
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
void hsr_dev_setup(struct net_device *dev); void hsr_dev_setup(struct net_device *dev);
int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
unsigned char multicast_spec, u8 protocol_version); unsigned char multicast_spec, u8 protocol_version,
struct netlink_ext_ack *extack);
void hsr_check_carrier_and_operstate(struct hsr_priv *hsr); void hsr_check_carrier_and_operstate(struct hsr_priv *hsr);
bool is_hsr_master(struct net_device *dev); bool is_hsr_master(struct net_device *dev);
int hsr_get_max_mtu(struct hsr_priv *hsr); int hsr_get_max_mtu(struct hsr_priv *hsr);
......
...@@ -318,7 +318,8 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb, ...@@ -318,7 +318,8 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
node_dst = find_node_by_addr_A(&port->hsr->node_db, node_dst = find_node_by_addr_A(&port->hsr->node_db,
eth_hdr(skb)->h_dest); eth_hdr(skb)->h_dest);
if (!node_dst) { if (!node_dst) {
WARN_ONCE(1, "%s: Unknown node\n", __func__); if (net_ratelimit())
netdev_err(skb->dev, "%s: Unknown node\n", __func__);
return; return;
} }
if (port->type != node_dst->addr_B_port) if (port->type != node_dst->addr_B_port)
......
...@@ -85,6 +85,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event, ...@@ -85,6 +85,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
master->dev->mtu = mtu_max; master->dev->mtu = mtu_max;
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
if (!is_hsr_master(dev))
hsr_del_port(port); hsr_del_port(port);
break; break;
case NETDEV_PRE_TYPE_CHANGE: case NETDEV_PRE_TYPE_CHANGE:
......
...@@ -166,7 +166,6 @@ struct hsr_priv { ...@@ -166,7 +166,6 @@ struct hsr_priv {
unsigned char sup_multicast_addr[ETH_ALEN]; unsigned char sup_multicast_addr[ETH_ALEN];
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *node_tbl_root; struct dentry *node_tbl_root;
struct dentry *node_tbl_file;
#endif #endif
}; };
......
...@@ -35,26 +35,34 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, ...@@ -35,26 +35,34 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
unsigned char multicast_spec, hsr_version; unsigned char multicast_spec, hsr_version;
if (!data) { if (!data) {
netdev_info(dev, "HSR: No slave devices specified\n"); NL_SET_ERR_MSG_MOD(extack, "No slave devices specified");
return -EINVAL; return -EINVAL;
} }
if (!data[IFLA_HSR_SLAVE1]) { if (!data[IFLA_HSR_SLAVE1]) {
netdev_info(dev, "HSR: Slave1 device not specified\n"); NL_SET_ERR_MSG_MOD(extack, "Slave1 device not specified");
return -EINVAL; return -EINVAL;
} }
link[0] = __dev_get_by_index(src_net, link[0] = __dev_get_by_index(src_net,
nla_get_u32(data[IFLA_HSR_SLAVE1])); nla_get_u32(data[IFLA_HSR_SLAVE1]));
if (!link[0]) {
NL_SET_ERR_MSG_MOD(extack, "Slave1 does not exist");
return -EINVAL;
}
if (!data[IFLA_HSR_SLAVE2]) { if (!data[IFLA_HSR_SLAVE2]) {
netdev_info(dev, "HSR: Slave2 device not specified\n"); NL_SET_ERR_MSG_MOD(extack, "Slave2 device not specified");
return -EINVAL; return -EINVAL;
} }
link[1] = __dev_get_by_index(src_net, link[1] = __dev_get_by_index(src_net,
nla_get_u32(data[IFLA_HSR_SLAVE2])); nla_get_u32(data[IFLA_HSR_SLAVE2]));
if (!link[1]) {
NL_SET_ERR_MSG_MOD(extack, "Slave2 does not exist");
return -EINVAL;
}
if (!link[0] || !link[1]) if (link[0] == link[1]) {
return -ENODEV; NL_SET_ERR_MSG_MOD(extack, "Slave1 and Slave2 are same");
if (link[0] == link[1])
return -EINVAL; return -EINVAL;
}
if (!data[IFLA_HSR_MULTICAST_SPEC]) if (!data[IFLA_HSR_MULTICAST_SPEC])
multicast_spec = 0; multicast_spec = 0;
...@@ -66,34 +74,25 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, ...@@ -66,34 +74,25 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
else else
hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]); hsr_version = nla_get_u8(data[IFLA_HSR_VERSION]);
return hsr_dev_finalize(dev, link, multicast_spec, hsr_version); return hsr_dev_finalize(dev, link, multicast_spec, hsr_version, extack);
} }
static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev) static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
{ {
struct hsr_priv *hsr; struct hsr_priv *hsr = netdev_priv(dev);
struct hsr_port *port; struct hsr_port *port;
int res;
hsr = netdev_priv(dev);
res = 0;
rcu_read_lock();
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
if (port) if (port) {
res = nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex); if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
rcu_read_unlock();
if (res)
goto nla_put_failure; goto nla_put_failure;
}
rcu_read_lock();
port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B); port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
if (port) if (port) {
res = nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex); if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
rcu_read_unlock();
if (res)
goto nla_put_failure; goto nla_put_failure;
}
if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN, if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
hsr->sup_multicast_addr) || hsr->sup_multicast_addr) ||
......
...@@ -25,7 +25,6 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) ...@@ -25,7 +25,6 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
return RX_HANDLER_PASS; return RX_HANDLER_PASS;
} }
rcu_read_lock(); /* hsr->node_db, hsr->ports */
port = hsr_port_get_rcu(skb->dev); port = hsr_port_get_rcu(skb->dev);
if (!port) if (!port)
goto finish_pass; goto finish_pass;
...@@ -45,11 +44,9 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) ...@@ -45,11 +44,9 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
hsr_forward_skb(skb, port); hsr_forward_skb(skb, port);
finish_consume: finish_consume:
rcu_read_unlock(); /* hsr->node_db, hsr->ports */
return RX_HANDLER_CONSUMED; return RX_HANDLER_CONSUMED;
finish_pass: finish_pass:
rcu_read_unlock(); /* hsr->node_db, hsr->ports */
return RX_HANDLER_PASS; return RX_HANDLER_PASS;
} }
...@@ -58,33 +55,37 @@ bool hsr_port_exists(const struct net_device *dev) ...@@ -58,33 +55,37 @@ bool hsr_port_exists(const struct net_device *dev)
return rcu_access_pointer(dev->rx_handler) == hsr_handle_frame; return rcu_access_pointer(dev->rx_handler) == hsr_handle_frame;
} }
static int hsr_check_dev_ok(struct net_device *dev) static int hsr_check_dev_ok(struct net_device *dev,
struct netlink_ext_ack *extack)
{ {
/* Don't allow HSR on non-ethernet like devices */ /* Don't allow HSR on non-ethernet like devices */
if ((dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER || if ((dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER ||
dev->addr_len != ETH_ALEN) { dev->addr_len != ETH_ALEN) {
netdev_info(dev, "Cannot use loopback or non-ethernet device as HSR slave.\n"); NL_SET_ERR_MSG_MOD(extack, "Cannot use loopback or non-ethernet device as HSR slave.");
return -EINVAL; return -EINVAL;
} }
/* Don't allow enslaving hsr devices */ /* Don't allow enslaving hsr devices */
if (is_hsr_master(dev)) { if (is_hsr_master(dev)) {
netdev_info(dev, "Cannot create trees of HSR devices.\n"); NL_SET_ERR_MSG_MOD(extack,
"Cannot create trees of HSR devices.");
return -EINVAL; return -EINVAL;
} }
if (hsr_port_exists(dev)) { if (hsr_port_exists(dev)) {
netdev_info(dev, "This device is already a HSR slave.\n"); NL_SET_ERR_MSG_MOD(extack,
"This device is already a HSR slave.");
return -EINVAL; return -EINVAL;
} }
if (is_vlan_dev(dev)) { if (is_vlan_dev(dev)) {
netdev_info(dev, "HSR on top of VLAN is not yet supported in this driver.\n"); NL_SET_ERR_MSG_MOD(extack, "HSR on top of VLAN is not yet supported in this driver.");
return -EINVAL; return -EINVAL;
} }
if (dev->priv_flags & IFF_DONT_BRIDGE) { if (dev->priv_flags & IFF_DONT_BRIDGE) {
netdev_info(dev, "This device does not support bridging.\n"); NL_SET_ERR_MSG_MOD(extack,
"This device does not support bridging.");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -96,19 +97,25 @@ static int hsr_check_dev_ok(struct net_device *dev) ...@@ -96,19 +97,25 @@ static int hsr_check_dev_ok(struct net_device *dev)
} }
/* Setup device to be added to the HSR bridge. */ /* Setup device to be added to the HSR bridge. */
static int hsr_portdev_setup(struct net_device *dev, struct hsr_port *port) static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,
struct hsr_port *port,
struct netlink_ext_ack *extack)
{ {
struct net_device *hsr_dev;
struct hsr_port *master;
int res; int res;
dev_hold(dev);
res = dev_set_promiscuity(dev, 1); res = dev_set_promiscuity(dev, 1);
if (res) if (res)
goto fail_promiscuity; goto fail_promiscuity;
/* FIXME: master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
* What does net device "adjacency" mean? Should we do hsr_dev = master->dev;
* res = netdev_master_upper_dev_link(port->dev, port->hsr->dev); ?
*/ res = netdev_upper_dev_link(dev, hsr_dev, extack);
if (res)
goto fail_upper_dev_link;
res = netdev_rx_handler_register(dev, hsr_handle_frame, port); res = netdev_rx_handler_register(dev, hsr_handle_frame, port);
if (res) if (res)
...@@ -118,6 +125,8 @@ static int hsr_portdev_setup(struct net_device *dev, struct hsr_port *port) ...@@ -118,6 +125,8 @@ static int hsr_portdev_setup(struct net_device *dev, struct hsr_port *port)
return 0; return 0;
fail_rx_handler: fail_rx_handler:
netdev_upper_dev_unlink(dev, hsr_dev);
fail_upper_dev_link:
dev_set_promiscuity(dev, -1); dev_set_promiscuity(dev, -1);
fail_promiscuity: fail_promiscuity:
dev_put(dev); dev_put(dev);
...@@ -126,13 +135,13 @@ static int hsr_portdev_setup(struct net_device *dev, struct hsr_port *port) ...@@ -126,13 +135,13 @@ static int hsr_portdev_setup(struct net_device *dev, struct hsr_port *port)
} }
int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev, int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
enum hsr_port_type type) enum hsr_port_type type, struct netlink_ext_ack *extack)
{ {
struct hsr_port *port, *master; struct hsr_port *port, *master;
int res; int res;
if (type != HSR_PT_MASTER) { if (type != HSR_PT_MASTER) {
res = hsr_check_dev_ok(dev); res = hsr_check_dev_ok(dev, extack);
if (res) if (res)
return res; return res;
} }
...@@ -146,7 +155,7 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev, ...@@ -146,7 +155,7 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
return -ENOMEM; return -ENOMEM;
if (type != HSR_PT_MASTER) { if (type != HSR_PT_MASTER) {
res = hsr_portdev_setup(dev, port); res = hsr_portdev_setup(hsr, dev, port, extack);
if (res) if (res)
goto fail_dev_setup; goto fail_dev_setup;
} }
...@@ -179,21 +188,14 @@ void hsr_del_port(struct hsr_port *port) ...@@ -179,21 +188,14 @@ void hsr_del_port(struct hsr_port *port)
list_del_rcu(&port->port_list); list_del_rcu(&port->port_list);
if (port != master) { if (port != master) {
if (master) {
netdev_update_features(master->dev); netdev_update_features(master->dev);
dev_set_mtu(master->dev, hsr_get_max_mtu(hsr)); dev_set_mtu(master->dev, hsr_get_max_mtu(hsr));
}
netdev_rx_handler_unregister(port->dev); netdev_rx_handler_unregister(port->dev);
dev_set_promiscuity(port->dev, -1); dev_set_promiscuity(port->dev, -1);
netdev_upper_dev_unlink(port->dev, master->dev);
} }
/* FIXME?
* netdev_upper_dev_unlink(port->dev, port->hsr->dev);
*/
synchronize_rcu(); synchronize_rcu();
if (port != master)
dev_put(port->dev);
kfree(port); kfree(port);
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "hsr_main.h" #include "hsr_main.h"
int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev, int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
enum hsr_port_type pt); enum hsr_port_type pt, struct netlink_ext_ack *extack);
void hsr_del_port(struct hsr_port *port); void hsr_del_port(struct hsr_port *port);
bool hsr_port_exists(const struct net_device *dev); bool hsr_port_exists(const struct net_device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment