Skip to content

Commit c8cdaf9

Browse files
committed
[IPV4,IPV6]: Share cork.rt between IPv4 and IPv6.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
1 parent a9b0572 commit c8cdaf9

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

‎include/linux/ipv6.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ struct ipv6_pinfo {
315315
struct sk_buff *pktoptions;
316316
struct {
317317
struct ipv6_txoptions *opt;
318-
struct rt6_info *rt;
319318
int hop_limit;
320319
int tclass;
321320
} cork;

‎include/net/inet_sock.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct inet_sock {
136136
unsigned int flags;
137137
unsigned int fragsize;
138138
struct ip_options *opt;
139-
struct rtable *rt;
139+
struct dst_entry *dst;
140140
int length; /* Total length of all frames */
141141
__be32 addr;
142142
struct flowi fl;

‎net/ipv4/ip_output.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ int ip_append_data(struct sock *sk,
825825
inet->cork.fragsize = mtu = inet->pmtudisc == IP_PMTUDISC_PROBE ?
826826
rt->u.dst.dev->mtu :
827827
dst_mtu(rt->u.dst.path);
828-
inet->cork.rt = rt;
828+
inet->cork.dst = &rt->u.dst;
829829
inet->cork.length = 0;
830830
sk->sk_sndmsg_page = NULL;
831831
sk->sk_sndmsg_off = 0;
@@ -834,7 +834,7 @@ int ip_append_data(struct sock *sk,
834834
transhdrlen += exthdrlen;
835835
}
836836
} else {
837-
rt = inet->cork.rt;
837+
rt = (struct rtable *)inet->cork.dst;
838838
if (inet->cork.flags & IPCORK_OPT)
839839
opt = inet->cork.opt;
840840

@@ -1083,7 +1083,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
10831083
if (skb_queue_empty(&sk->sk_write_queue))
10841084
return -EINVAL;
10851085

1086-
rt = inet->cork.rt;
1086+
rt = (struct rtable *)inet->cork.dst;
10871087
if (inet->cork.flags & IPCORK_OPT)
10881088
opt = inet->cork.opt;
10891089

@@ -1208,10 +1208,8 @@ static void ip_cork_release(struct inet_sock *inet)
12081208
inet->cork.flags &= ~IPCORK_OPT;
12091209
kfree(inet->cork.opt);
12101210
inet->cork.opt = NULL;
1211-
if (inet->cork.rt) {
1212-
ip_rt_put(inet->cork.rt);
1213-
inet->cork.rt = NULL;
1214-
}
1211+
dst_release(inet->cork.dst);
1212+
inet->cork.dst = NULL;
12151213
}
12161214

12171215
/*
@@ -1224,7 +1222,7 @@ int ip_push_pending_frames(struct sock *sk)
12241222
struct sk_buff **tail_skb;
12251223
struct inet_sock *inet = inet_sk(sk);
12261224
struct ip_options *opt = NULL;
1227-
struct rtable *rt = inet->cork.rt;
1225+
struct rtable *rt = (struct rtable *)inet->cork.dst;
12281226
struct iphdr *iph;
12291227
__be16 df = 0;
12301228
__u8 ttl;

‎net/ipv6/ip6_output.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
11151115
/* need source address above miyazawa*/
11161116
}
11171117
dst_hold(&rt->u.dst);
1118-
np->cork.rt = rt;
1118+
inet->cork.dst = &rt->u.dst;
11191119
inet->cork.fl = *fl;
11201120
np->cork.hop_limit = hlimit;
11211121
np->cork.tclass = tclass;
@@ -1136,7 +1136,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
11361136
length += exthdrlen;
11371137
transhdrlen += exthdrlen;
11381138
} else {
1139-
rt = np->cork.rt;
1139+
rt = (struct rt6_info *)inet->cork.dst;
11401140
fl = &inet->cork.fl;
11411141
if (inet->cork.flags & IPCORK_OPT)
11421142
opt = np->cork.opt;
@@ -1381,9 +1381,9 @@ static void ip6_cork_release(struct inet_sock *inet, struct ipv6_pinfo *np)
13811381
inet->cork.flags &= ~IPCORK_OPT;
13821382
kfree(np->cork.opt);
13831383
np->cork.opt = NULL;
1384-
if (np->cork.rt) {
1385-
dst_release(&np->cork.rt->u.dst);
1386-
np->cork.rt = NULL;
1384+
if (inet->cork.dst) {
1385+
dst_release(inet->cork.dst);
1386+
inet->cork.dst = NULL;
13871387
inet->cork.flags &= ~IPCORK_ALLFRAG;
13881388
}
13891389
memset(&inet->cork.fl, 0, sizeof(inet->cork.fl));
@@ -1398,7 +1398,7 @@ int ip6_push_pending_frames(struct sock *sk)
13981398
struct ipv6_pinfo *np = inet6_sk(sk);
13991399
struct ipv6hdr *hdr;
14001400
struct ipv6_txoptions *opt = np->cork.opt;
1401-
struct rt6_info *rt = np->cork.rt;
1401+
struct rt6_info *rt = (struct rt6_info *)inet->cork.dst;
14021402
struct flowi *fl = &inet->cork.fl;
14031403
unsigned char proto = fl->proto;
14041404
int err = 0;

0 commit comments

Comments
 (0)