From: Eric Dumazet Date: Wed, 16 Aug 2023 08:15:40 +0000 (+0000) Subject: inet: move inet->mc_all to inet->inet_frags X-Git-Tag: v6.6.7~2079^2~103^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=307b4ac6dc18436076cdd314aa3e556be077bf2d;p=platform%2Fkernel%2Flinux-starfive.git inet: move inet->mc_all to inet->inet_frags IP_MULTICAST_ALL socket option can now be set/read without locking the socket. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Reviewed-by: Simon Horman Signed-off-by: David S. Miller --- diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 6c4eeca..fffd34f 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -232,7 +232,6 @@ struct inet_sock { __u8 pmtudisc; __u8 is_icsk:1, transparent:1, - mc_all:1, nodefrag:1; __u8 bind_address_no_port:1, defer_connect:1; /* Indicates that fastopen_connect is set @@ -271,6 +270,7 @@ enum { INET_FLAGS_FREEBIND = 11, INET_FLAGS_HDRINCL = 12, INET_FLAGS_MC_LOOP = 13, + INET_FLAGS_MC_ALL = 14, }; /* cmsg flags for inet */ diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index e847822..47c9cdd 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -358,7 +358,7 @@ lookup_protocol: inet->uc_ttl = -1; inet_set_bit(MC_LOOP, sk); inet->mc_ttl = 1; - inet->mc_all = 1; + inet_set_bit(MC_ALL, sk); inet->mc_index = 0; inet->mc_list = NULL; inet->rcv_tos = 0; diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 48ff5f1..0c9e768 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -2658,7 +2658,7 @@ int ip_mc_sf_allow(const struct sock *sk, __be32 loc_addr, __be32 rmt_addr, (sdif && pmc->multi.imr_ifindex == sdif))) break; } - ret = inet->mc_all; + ret = inet_test_bit(MC_ALL, sk); if (!pmc) goto unlock; psl = rcu_dereference(pmc->sflist); diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index cc79726..e009dab 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -188,7 +188,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb, inet_sockopt.hdrincl = inet_test_bit(HDRINCL, sk); inet_sockopt.mc_loop = inet_test_bit(MC_LOOP, sk); inet_sockopt.transparent = inet->transparent; - inet_sockopt.mc_all = inet->mc_all; + inet_sockopt.mc_all = inet_test_bit(MC_ALL, sk); inet_sockopt.nodefrag = inet->nodefrag; inet_sockopt.bind_address_no_port = inet->bind_address_no_port; inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index be56903..2f27c30 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -998,6 +998,14 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, return -EINVAL; inet_assign_bit(MC_LOOP, sk, val); return 0; + case IP_MULTICAST_ALL: + if (optlen < 1) + return -EINVAL; + if (val != 0 && val != 1) + return -EINVAL; + inet_assign_bit(MC_ALL, sk, val); + return 0; + } err = 0; @@ -1303,14 +1311,6 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, else err = ip_set_mcast_msfilter(sk, optval, optlen); break; - case IP_MULTICAST_ALL: - if (optlen < 1) - goto e_inval; - if (val != 0 && val != 1) - goto e_inval; - inet->mc_all = val; - break; - case IP_IPSEC_POLICY: case IP_XFRM_POLICY: err = -EPERM; @@ -1582,6 +1582,9 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, case IP_MULTICAST_LOOP: val = inet_test_bit(MC_LOOP, sk); goto copyval; + case IP_MULTICAST_ALL: + val = inet_test_bit(MC_ALL, sk); + goto copyval; } if (needs_rtnl) @@ -1694,9 +1697,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, else err = ip_get_mcast_msfilter(sk, optval, optlen, len); goto out; - case IP_MULTICAST_ALL: - val = inet->mc_all; - break; case IP_PKTOPTIONS: { struct msghdr msg;