Commit 77589ce0 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

ipv4: Cache net in ip_build_and_send_pkt and ip_queue_xmit

Compute net and store it in a variable in the functions
ip_build_and_send_pkt and ip_queue_xmit so that it does not need to be
recomputed next time it is needed.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f859b0f6
...@@ -139,6 +139,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk, ...@@ -139,6 +139,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct rtable *rt = skb_rtable(skb); struct rtable *rt = skb_rtable(skb);
struct net *net = sock_net(sk);
struct iphdr *iph; struct iphdr *iph;
/* Build the IP header. */ /* Build the IP header. */
...@@ -157,7 +158,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk, ...@@ -157,7 +158,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
iph->id = 0; iph->id = 0;
} else { } else {
iph->frag_off = 0; iph->frag_off = 0;
__ip_select_ident(sock_net(sk), iph, 1); __ip_select_ident(net, iph, 1);
} }
if (opt && opt->opt.optlen) { if (opt && opt->opt.optlen) {
...@@ -382,6 +383,7 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4) ...@@ -382,6 +383,7 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl) int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct net *net = sock_net(sk);
struct ip_options_rcu *inet_opt; struct ip_options_rcu *inet_opt;
struct flowi4 *fl4; struct flowi4 *fl4;
struct rtable *rt; struct rtable *rt;
...@@ -412,7 +414,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl) ...@@ -412,7 +414,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
* keep trying until route appears or the connection times * keep trying until route appears or the connection times
* itself out. * itself out.
*/ */
rt = ip_route_output_ports(sock_net(sk), fl4, sk, rt = ip_route_output_ports(net, fl4, sk,
daddr, inet->inet_saddr, daddr, inet->inet_saddr,
inet->inet_dport, inet->inet_dport,
inet->inet_sport, inet->inet_sport,
...@@ -449,7 +451,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl) ...@@ -449,7 +451,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0); ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
} }
ip_select_ident_segs(sock_net(sk), skb, sk, ip_select_ident_segs(net, skb, sk,
skb_shinfo(skb)->gso_segs ?: 1); skb_shinfo(skb)->gso_segs ?: 1);
/* TODO : should we use skb->sk here instead of sk ? */ /* TODO : should we use skb->sk here instead of sk ? */
...@@ -462,7 +464,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl) ...@@ -462,7 +464,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
no_route: no_route:
rcu_read_unlock(); rcu_read_unlock();
IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
kfree_skb(skb); kfree_skb(skb);
return -EHOSTUNREACH; return -EHOSTUNREACH;
} }
......
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