提交 bb23ffa1 编写于 作者: C Christophe JAILLET 提交者: David S. Miller

macvlan: Use 'hash' iterators to simplify code

Use 'hash_for_each_rcu' and 'hash_for_each_safe' instead of hand writing
them. This saves some lines of code, reduce indentation and improve
readability.
Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 99014088
...@@ -272,8 +272,7 @@ static void macvlan_broadcast(struct sk_buff *skb, ...@@ -272,8 +272,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
if (skb->protocol == htons(ETH_P_PAUSE)) if (skb->protocol == htons(ETH_P_PAUSE))
return; return;
for (i = 0; i < MACVLAN_HASH_SIZE; i++) { hash_for_each_rcu(port->vlan_hash, i, vlan, hlist) {
hlist_for_each_entry_rcu(vlan, &port->vlan_hash[i], hlist) {
if (vlan->dev == src || !(vlan->mode & mode)) if (vlan->dev == src || !(vlan->mode & mode))
continue; continue;
...@@ -284,14 +283,12 @@ static void macvlan_broadcast(struct sk_buff *skb, ...@@ -284,14 +283,12 @@ static void macvlan_broadcast(struct sk_buff *skb,
err = NET_RX_DROP; err = NET_RX_DROP;
nskb = skb_clone(skb, GFP_ATOMIC); nskb = skb_clone(skb, GFP_ATOMIC);
if (likely(nskb)) if (likely(nskb))
err = macvlan_broadcast_one( err = macvlan_broadcast_one(nskb, vlan, eth,
nskb, vlan, eth,
mode == MACVLAN_MODE_BRIDGE) ?: mode == MACVLAN_MODE_BRIDGE) ?:
netif_rx_ni(nskb); netif_rx_ni(nskb);
macvlan_count_rx(vlan, skb->len + ETH_HLEN, macvlan_count_rx(vlan, skb->len + ETH_HLEN,
err == NET_RX_SUCCESS, true); err == NET_RX_SUCCESS, true);
} }
}
} }
static void macvlan_process_broadcast(struct work_struct *w) static void macvlan_process_broadcast(struct work_struct *w)
...@@ -380,20 +377,14 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port, ...@@ -380,20 +377,14 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
static void macvlan_flush_sources(struct macvlan_port *port, static void macvlan_flush_sources(struct macvlan_port *port,
struct macvlan_dev *vlan) struct macvlan_dev *vlan)
{ {
int i;
for (i = 0; i < MACVLAN_HASH_SIZE; i++) {
struct hlist_node *h, *n;
hlist_for_each_safe(h, n, &port->vlan_source_hash[i]) {
struct macvlan_source_entry *entry; struct macvlan_source_entry *entry;
struct hlist_node *next;
int i;
entry = hlist_entry(h, struct macvlan_source_entry, hash_for_each_safe(port->vlan_source_hash, i, next, entry, hlist)
hlist);
if (entry->vlan == vlan) if (entry->vlan == vlan)
macvlan_hash_del_source(entry); macvlan_hash_del_source(entry);
}
}
vlan->macaddr_count = 0; vlan->macaddr_count = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册