Commit 1789a640 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

raw: avoid two atomics in xmit

Avoid two atomic ops per raw_send_hdrinc() call

Avoid two atomic ops per raw6_send_hdrinc() call
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe33147a
...@@ -314,7 +314,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -314,7 +314,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb)
} }
static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
struct rtable *rt, struct rtable **rtp,
unsigned int flags) unsigned int flags)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
...@@ -323,6 +323,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, ...@@ -323,6 +323,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
struct sk_buff *skb; struct sk_buff *skb;
unsigned int iphlen; unsigned int iphlen;
int err; int err;
struct rtable *rt = *rtp;
if (length > rt->u.dst.dev->mtu) { if (length > rt->u.dst.dev->mtu) {
ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport, ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport,
...@@ -341,7 +342,8 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length, ...@@ -341,7 +342,8 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
skb->priority = sk->sk_priority; skb->priority = sk->sk_priority;
skb->mark = sk->sk_mark; skb->mark = sk->sk_mark;
skb_dst_set(skb, dst_clone(&rt->u.dst)); skb_dst_set(skb, &rt->u.dst);
*rtp = NULL;
skb_reset_network_header(skb); skb_reset_network_header(skb);
iph = ip_hdr(skb); iph = ip_hdr(skb);
...@@ -576,7 +578,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -576,7 +578,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (inet->hdrincl) if (inet->hdrincl)
err = raw_send_hdrinc(sk, msg->msg_iov, len, err = raw_send_hdrinc(sk, msg->msg_iov, len,
rt, msg->msg_flags); &rt, msg->msg_flags);
else { else {
if (!ipc.addr) if (!ipc.addr)
......
...@@ -602,13 +602,14 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, ...@@ -602,13 +602,14 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
} }
static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
struct flowi *fl, struct rt6_info *rt, struct flowi *fl, struct dst_entry **dstp,
unsigned int flags) unsigned int flags)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6hdr *iph; struct ipv6hdr *iph;
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
struct rt6_info *rt = (struct rt6_info *)*dstp;
if (length > rt->u.dst.dev->mtu) { if (length > rt->u.dst.dev->mtu) {
ipv6_local_error(sk, EMSGSIZE, fl, rt->u.dst.dev->mtu); ipv6_local_error(sk, EMSGSIZE, fl, rt->u.dst.dev->mtu);
...@@ -626,7 +627,8 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, ...@@ -626,7 +627,8 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
skb->priority = sk->sk_priority; skb->priority = sk->sk_priority;
skb->mark = sk->sk_mark; skb->mark = sk->sk_mark;
skb_dst_set(skb, dst_clone(&rt->u.dst)); skb_dst_set(skb, &rt->u.dst);
*dstp = NULL;
skb_put(skb, length); skb_put(skb, length);
skb_reset_network_header(skb); skb_reset_network_header(skb);
...@@ -886,9 +888,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -886,9 +888,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
goto do_confirm; goto do_confirm;
back_from_confirm: back_from_confirm:
if (inet->hdrincl) { if (inet->hdrincl)
err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, (struct rt6_info*)dst, msg->msg_flags); err = rawv6_send_hdrinc(sk, msg->msg_iov, len, &fl, &dst, msg->msg_flags);
} else { else {
lock_sock(sk); lock_sock(sk);
err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov,
len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst, len, 0, hlimit, tclass, opt, &fl, (struct rt6_info*)dst,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment