diff options
author | David Held <drheld@google.com> | 2014-07-15 23:28:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-17 02:29:52 -0400 |
commit | 5cf3d46192fccf68b4a4759e4d7346e41c669a76 (patch) | |
tree | b2a162b9ee42c0842e3178eefb7759d64ebb0416 /net/ipv4/udp.c | |
parent | 3e1c0f0b06e38b50bfca197a6443d639353bb035 (diff) |
udp: Simplify __udp*_lib_mcast_deliver.
Switch to using sk_nulls_for_each which shortens the code and makes it
easier to update.
Signed-off-by: David Held <drheld@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 668af516f094..bbcc33737ef1 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -594,26 +594,6 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk, | |||
594 | return true; | 594 | return true; |
595 | } | 595 | } |
596 | 596 | ||
597 | static inline struct sock *udp_v4_mcast_next(struct net *net, struct sock *sk, | ||
598 | __be16 loc_port, __be32 loc_addr, | ||
599 | __be16 rmt_port, __be32 rmt_addr, | ||
600 | int dif) | ||
601 | { | ||
602 | struct hlist_nulls_node *node; | ||
603 | unsigned short hnum = ntohs(loc_port); | ||
604 | |||
605 | sk_nulls_for_each_from(sk, node) { | ||
606 | if (__udp_is_mcast_sock(net, sk, | ||
607 | loc_port, loc_addr, | ||
608 | rmt_port, rmt_addr, | ||
609 | dif, hnum)) | ||
610 | goto found; | ||
611 | } | ||
612 | sk = NULL; | ||
613 | found: | ||
614 | return sk; | ||
615 | } | ||
616 | |||
617 | /* | 597 | /* |
618 | * This routine is called by the ICMP module when it gets some | 598 | * This routine is called by the ICMP module when it gets some |
619 | * sort of error condition. If err < 0 then the socket should | 599 | * sort of error condition. If err < 0 then the socket should |
@@ -1667,23 +1647,23 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
1667 | struct udp_table *udptable) | 1647 | struct udp_table *udptable) |
1668 | { | 1648 | { |
1669 | struct sock *sk, *stack[256 / sizeof(struct sock *)]; | 1649 | struct sock *sk, *stack[256 / sizeof(struct sock *)]; |
1670 | struct udp_hslot *hslot = udp_hashslot(udptable, net, ntohs(uh->dest)); | 1650 | struct hlist_nulls_node *node; |
1671 | int dif; | 1651 | unsigned short hnum = ntohs(uh->dest); |
1652 | struct udp_hslot *hslot = udp_hashslot(udptable, net, hnum); | ||
1653 | int dif = skb->dev->ifindex; | ||
1672 | unsigned int i, count = 0; | 1654 | unsigned int i, count = 0; |
1673 | 1655 | ||
1674 | spin_lock(&hslot->lock); | 1656 | spin_lock(&hslot->lock); |
1675 | sk = sk_nulls_head(&hslot->head); | 1657 | sk_nulls_for_each(sk, node, &hslot->head) { |
1676 | dif = skb->dev->ifindex; | 1658 | if (__udp_is_mcast_sock(net, sk, |
1677 | sk = udp_v4_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif); | 1659 | uh->dest, daddr, |
1678 | while (sk) { | 1660 | uh->source, saddr, |
1679 | stack[count++] = sk; | 1661 | dif, hnum)) { |
1680 | sk = udp_v4_mcast_next(net, sk_nulls_next(sk), uh->dest, | 1662 | if (unlikely(count == ARRAY_SIZE(stack))) { |
1681 | daddr, uh->source, saddr, dif); | 1663 | flush_stack(stack, count, skb, ~0); |
1682 | if (unlikely(count == ARRAY_SIZE(stack))) { | 1664 | count = 0; |
1683 | if (!sk) | 1665 | } |
1684 | break; | 1666 | stack[count++] = sk; |
1685 | flush_stack(stack, count, skb, ~0); | ||
1686 | count = 0; | ||
1687 | } | 1667 | } |
1688 | } | 1668 | } |
1689 | /* | 1669 | /* |