提交 11878b40 编写于 作者: W Willem de Bruijn 提交者: David S. Miller

net-timestamp: SOCK_RAW and PING timestamping

Add SO_TIMESTAMPING to sockets of type PF_INET[6]/SOCK_RAW:

Add the necessary sock_tx_timestamp calls to the datapath for RAW
sockets (ping sockets already had these calls).

Fix the IP output path to pass the timestamp flags on the first
fragment also for these sockets. The existing code relies on
transhdrlen != 0 to indicate a first fragment. For these sockets,
that assumption does not hold.

This fixes http://bugzilla.kernel.org/show_bug.cgi?id=77221

Tested SOCK_RAW on IPv4 and IPv6, not PING.
Signed-off-by: NWillem de Bruijn <willemb@google.com>
Acked-by: NRichard Cochran <richardcochran@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d5c1c936
...@@ -962,10 +962,6 @@ static int __ip_append_data(struct sock *sk, ...@@ -962,10 +962,6 @@ static int __ip_append_data(struct sock *sk,
sk->sk_allocation); sk->sk_allocation);
if (unlikely(skb == NULL)) if (unlikely(skb == NULL))
err = -ENOBUFS; err = -ENOBUFS;
else
/* only the initial fragment is
time stamped */
cork->tx_flags = 0;
} }
if (skb == NULL) if (skb == NULL)
goto error; goto error;
...@@ -976,7 +972,10 @@ static int __ip_append_data(struct sock *sk, ...@@ -976,7 +972,10 @@ static int __ip_append_data(struct sock *sk,
skb->ip_summed = csummode; skb->ip_summed = csummode;
skb->csum = 0; skb->csum = 0;
skb_reserve(skb, hh_len); skb_reserve(skb, hh_len);
/* only the initial fragment is time stamped */
skb_shinfo(skb)->tx_flags = cork->tx_flags; skb_shinfo(skb)->tx_flags = cork->tx_flags;
cork->tx_flags = 0;
/* /*
* Find where to start putting bytes. * Find where to start putting bytes.
......
...@@ -365,6 +365,8 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4, ...@@ -365,6 +365,8 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags);
skb->transport_header = skb->network_header; skb->transport_header = skb->network_header;
err = -EFAULT; err = -EFAULT;
if (memcpy_fromiovecend((void *)iph, from, 0, length)) if (memcpy_fromiovecend((void *)iph, from, 0, length))
...@@ -606,6 +608,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -606,6 +608,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
&rt, msg->msg_flags); &rt, msg->msg_flags);
else { else {
sock_tx_timestamp(sk, &ipc.tx_flags);
if (!ipc.addr) if (!ipc.addr)
ipc.addr = fl4.daddr; ipc.addr = fl4.daddr;
lock_sock(sk); lock_sock(sk);
......
...@@ -1271,7 +1271,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, ...@@ -1271,7 +1271,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
} }
/* For UDP, check if TX timestamp is enabled */ /* For UDP, check if TX timestamp is enabled */
if (sk->sk_type == SOCK_DGRAM) if (sk->sk_type == SOCK_DGRAM || sk->sk_type == SOCK_RAW)
sock_tx_timestamp(sk, &tx_flags); sock_tx_timestamp(sk, &tx_flags);
/* /*
...@@ -1380,12 +1380,6 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, ...@@ -1380,12 +1380,6 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
sk->sk_allocation); sk->sk_allocation);
if (unlikely(skb == NULL)) if (unlikely(skb == NULL))
err = -ENOBUFS; err = -ENOBUFS;
else {
/* Only the initial fragment
* is time stamped.
*/
tx_flags = 0;
}
} }
if (skb == NULL) if (skb == NULL)
goto error; goto error;
...@@ -1399,8 +1393,9 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, ...@@ -1399,8 +1393,9 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
skb_reserve(skb, hh_len + sizeof(struct frag_hdr) + skb_reserve(skb, hh_len + sizeof(struct frag_hdr) +
dst_exthdrlen); dst_exthdrlen);
if (sk->sk_type == SOCK_DGRAM) /* Only the initial fragment is time stamped */
skb_shinfo(skb)->tx_flags = tx_flags; skb_shinfo(skb)->tx_flags = tx_flags;
tx_flags = 0;
/* /*
* Find where to start putting bytes * Find where to start putting bytes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册