diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-02-09 16:36:41 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-02-10 15:04:51 +0000 |
commit | 3ebb0b1032e55614672af10c491302018bf34fd4 (patch) | |
tree | e70a5aff547f86325b20470e09d632315f867955 | |
parent | e7b060460f29c31a550cb563819c69f2b1cb7b10 (diff) | |
download | linux-3ebb0b1032e55614672af10c491302018bf34fd4.tar.gz linux-3ebb0b1032e55614672af10c491302018bf34fd4.tar.bz2 linux-3ebb0b1032e55614672af10c491302018bf34fd4.zip |
net: ping6: support setting socket options via cmsg
Minor reordering of the code and a call to sock_cmsg_send()
gives us support for setting the common socket options via
cmsg (the usual ones - SO_MARK, SO_TIMESTAMPING_OLD, SCM_TXTIME).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/ping.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index 3228ccd8abf1..d5544cf67ffe 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c @@ -97,6 +97,14 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) (oif && sk->sk_bound_dev_if && oif != sk->sk_bound_dev_if)) return -EINVAL; + ipcm6_init_sk(&ipc6, np); + ipc6.sockc.tsflags = sk->sk_tsflags; + ipc6.sockc.mark = sk->sk_mark; + + err = sock_cmsg_send(sk, msg, &ipc6.sockc); + if (err) + return err; + /* TODO: use ip6_datagram_send_ctl to get options from cmsg */ memset(&fl6, 0, sizeof(fl6)); @@ -105,15 +113,12 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) fl6.saddr = np->saddr; fl6.daddr = *daddr; fl6.flowi6_oif = oif; - fl6.flowi6_mark = sk->sk_mark; + fl6.flowi6_mark = ipc6.sockc.mark; fl6.flowi6_uid = sk->sk_uid; fl6.fl6_icmp_type = user_icmph.icmp6_type; fl6.fl6_icmp_code = user_icmph.icmp6_code; security_sk_classify_flow(sk, flowi6_to_flowi_common(&fl6)); - ipcm6_init_sk(&ipc6, np); - ipc6.sockc.mark = sk->sk_mark; - ipc6.sockc.tsflags = sk->sk_tsflags; fl6.flowlabel = ip6_make_flowinfo(ipc6.tclass, fl6.flowlabel); dst = ip6_sk_dst_lookup_flow(sk, &fl6, daddr, false); |