mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 16:47:42 +00:00
net: initialize mark in sockcm_init
Avoid open coding initialization of sockcm fields. Avoid reading the sk_priority field twice. This ensures all callers, existing and future, will correctly try a cmsg passed mark before sk_mark. This patch extends support for cmsg mark to: packet_spkt and packet_tpacket and net/can/raw.c. This patch extends support for cmsg priority to: packet_spkt and packet_tpacket. Signed-off-by: Willem de Bruijn <willemb@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://patch.msgid.link/20250214222720.3205500-3-willemdebruijn.kernel@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
aaf6532d11
commit
6ad861519a
@ -1829,6 +1829,7 @@ static inline void sockcm_init(struct sockcm_cookie *sockc,
|
||||
const struct sock *sk)
|
||||
{
|
||||
*sockc = (struct sockcm_cookie) {
|
||||
.mark = READ_ONCE(sk->sk_mark),
|
||||
.tsflags = READ_ONCE(sk->sk_tsflags),
|
||||
.priority = READ_ONCE(sk->sk_priority),
|
||||
};
|
||||
|
@ -963,7 +963,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
|
||||
|
||||
skb->dev = dev;
|
||||
skb->priority = sockc.priority;
|
||||
skb->mark = READ_ONCE(sk->sk_mark);
|
||||
skb->mark = sockc.mark;
|
||||
skb->tstamp = sockc.transmit_time;
|
||||
|
||||
skb_setup_tx_timestamp(skb, &sockc);
|
||||
|
@ -2102,8 +2102,8 @@ retry:
|
||||
|
||||
skb->protocol = proto;
|
||||
skb->dev = dev;
|
||||
skb->priority = READ_ONCE(sk->sk_priority);
|
||||
skb->mark = READ_ONCE(sk->sk_mark);
|
||||
skb->priority = sockc.priority;
|
||||
skb->mark = sockc.mark;
|
||||
skb_set_delivery_type_by_clockid(skb, sockc.transmit_time, sk->sk_clockid);
|
||||
skb_setup_tx_timestamp(skb, &sockc);
|
||||
|
||||
@ -2634,8 +2634,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
|
||||
|
||||
skb->protocol = proto;
|
||||
skb->dev = dev;
|
||||
skb->priority = READ_ONCE(po->sk.sk_priority);
|
||||
skb->mark = READ_ONCE(po->sk.sk_mark);
|
||||
skb->priority = sockc->priority;
|
||||
skb->mark = sockc->mark;
|
||||
skb_set_delivery_type_by_clockid(skb, sockc->transmit_time, po->sk.sk_clockid);
|
||||
skb_setup_tx_timestamp(skb, sockc);
|
||||
skb_zcopy_set_nouarg(skb, ph.raw);
|
||||
@ -3039,7 +3039,6 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
|
||||
goto out_unlock;
|
||||
|
||||
sockcm_init(&sockc, sk);
|
||||
sockc.mark = READ_ONCE(sk->sk_mark);
|
||||
if (msg->msg_controllen) {
|
||||
err = sock_cmsg_send(sk, msg, &sockc);
|
||||
if (unlikely(err))
|
||||
|
Loading…
x
Reference in New Issue
Block a user