ipv4: Pass flow keys down into datagram packet building engine.
Subsystems (4)
David Miller
maintainerPATCH 1/2 ipv4: Pass flow keys down into datagram packet building engine.
This way ip_output.c no longer needs rt->rt_{src,dst}.
We already have these keys sitting, ready and waiting, on the stack or in a socket structure.
Signed-off-by David S. Miller <[email protected]>
--- include/net/ip.h | 8 +++-- net/ipv4/icmp.c | 74 ++++++++++++++++++++++++------------------------- net/ipv4/ip_output.c | 39 +++++++++++++------------- net/ipv4/raw.c | 59 +++++++++++++++++++-------------------- net/ipv4/udp.c | 4 +- 5 files changed, 91 insertions(+), 93 deletions(-)
include/net/ip.h +5 -3
@@ -117,12 +117,14 @@ extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odextern ssize_t ip_append_page (struct sock *sk,struct page *page,int offset,size_t size,int flags);extern struct sk_buff *__ip_make_skb (struct sock *sk, +struct flowi4 *fl4,struct sk_buff_head *queue,struct inet_cork *cork);extern int ip_send_skb (struct sk_buff *skb); -extern int ip_push_pending_frames (struct sock *sk); +extern int ip_push_pending_frames (struct sock *sk,struct flowi4 *fl4);extern void ip_flush_pending_frames (struct sock *sk); extern struct sk_buff *ip_make_skb(struct sock *sk, + struct flowi4 *fl4, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), void *from, int length, int transhdrlen,
@@ -130,9 +132,9 @@ extern struct sk_buff *ip_make_skb(struct sock *sk,struct rtable **rtp, unsigned int flags); -static inline struct sk_buff *ip_finish_skb (struct sock *sk) +static inline struct sk_buff *ip_finish_skb (struct sock *sk,struct flowi4 *fl4) { -return __ip_make_skb (sk, &sk->sk_write_queue, &inet_sk (sk)->cork.base); +return __ip_make_skb (sk, fl4, &sk->sk_write_queue, &inet_sk (sk)->cork.base); }/* datagram.c */
net/ipv4/icmp.c +36 -38
165 lines not on this page · raw message
net/ipv4/ip_output.c +19 -20
@@ -1267,6 +1267,7 @@ static void ip_cork_release(struct inet_cork *cork)* and push them out. */ struct sk_buff *__ip_make_skb (struct sock *sk, +struct flowi4 *fl4,struct sk_buff_head *queue,struct inet_cork *cork) {
@@ -1333,8 +1334,8 @@ struct sk_buff *__ip_make_skb(struct sock *sk,ip_select_ident (iph, &rt->dst, sk); iph->ttl = ttl; iph->protocol = sk->sk_protocol; - iph->saddr = rt->rt_src; - iph->daddr = rt->rt_dst; + iph->saddr = fl4->saddr; + iph->daddr = fl4->daddr; skb->priority = sk->sk_priority; skb->mark = sk->sk_mark;
@@ -1370,11 +1371,11 @@ int ip_send_skb(struct sk_buff *skb)return err; } -int ip_push_pending_frames (struct sock *sk) +int ip_push_pending_frames (struct sock *sk,struct flowi4 *fl4) {struct sk_buff *skb; - skb =ip_finish_skb (sk); + skb =ip_finish_skb (sk, fl4);if (!skb)return 0 ;
@@ -1403,6 +1404,7 @@ void ip_flush_pending_frames(struct sock *sk) } struct sk_buff *ip_make_skb(struct sock *sk, + struct flowi4 *fl4, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), void *from, int length, int transhdrlen,
@@ -1432,7 +1434,7 @@ struct sk_buff *ip_make_skb(struct sock *sk,return ERR_PTR (err); } -return __ip_make_skb (sk, &queue, &cork); +return __ip_make_skb (sk, fl4, &queue, &cork); }/*
@@ -1461,6 +1463,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arstruct inet_sock *inet =inet_sk (sk);struct ip_options_data replyopts;struct ipcm_cookie ipc; +struct flowi4 fl4;__be32 daddr;struct rtable *rt =skb_rtable (skb);
@@ -1478,20 +1481,16 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar daddr = replyopts.opt.opt.faddr; } - { -struct flowi4 fl4; - -flowi4_init_output (&fl4, arg->bound_dev_if,0 , -RT_TOS (ip_hdr (skb)->tos), -RT_SCOPE_UNIVERSE , sk->sk_protocol, -ip_reply_arg_flowi_flags (arg), - daddr, rt->rt_spec_dst, -tcp_hdr (skb)->source,tcp_hdr (skb)->dest); -security_skb_classify_flow (skb,flowi4_to_flowi (&fl4)); - rt =ip_route_output_key (sock_net (sk), &fl4); -if (IS_ERR (rt)) -return ; - } +flowi4_init_output (&fl4, arg->bound_dev_if,0 , +RT_TOS (ip_hdr (skb)->tos), +RT_SCOPE_UNIVERSE , sk->sk_protocol, +ip_reply_arg_flowi_flags (arg), + daddr, rt->rt_spec_dst, +tcp_hdr (skb)->source,tcp_hdr (skb)->dest); +security_skb_classify_flow (skb,flowi4_to_flowi (&fl4)); + rt =ip_route_output_key (sock_net (sk), &fl4); +if (IS_ERR (rt)) +return ;/* And let IP do all the hard work.
@@ -1512,7 +1511,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum)); skb->ip_summed =CHECKSUM_NONE ; -ip_push_pending_frames (sk); +ip_push_pending_frames (sk, &fl4); }bh_unlock_sock (sk);
net/ipv4/raw.c +29 -30
104 lines not on this page · raw message
net/ipv4/udp.c +2 -2
@@ -774,7 +774,7 @@ static int udp_push_pending_frames(struct sock *sk)struct sk_buff *skb;int err =0 ; - skb =ip_finish_skb (sk); + skb =ip_finish_skb (sk, fl4);if (!skb) goto out;
@@ -958,7 +958,7 @@ back_from_confirm:/* Lockless fast path for the non-corking case. */ if (!corkreq) { - skb =ip_make_skb (sk, getfrag, msg->msg_iov, ulen, + skb =ip_make_skb (sk, fl4, getfrag, msg->msg_iov, ulen,sizeof (struct udphdr ), &ipc, &rt, msg->msg_flags); err =PTR_ERR (skb);
Signature · 1 line
1.7.5.1
net/ipv4/icmp.c static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) · line 380
Quoted 8 lines · David Miller
net/ipv4/icmp.c +3
-0+static struct rtable *icmp_route_lookup (struct net *net, +struct flowi4 *fl4, +struct sk_buff *skb_in,const struct iphdr *iph,__be32 saddr,u8 tos,int type,int code,struct icmp_bxm *param) {
[]
Review
Quoted 1 line
(quoted diff) +1
-0+ memset(&fl4, 0, sizeof(fl4));
memset(fl4, 0, sizeof(*fl4));
Quoted 2 lines
net/ipv4/icmp.c +2
-0+ fl4->daddr = (param->replyopts.opt.opt.srr ? + param->replyopts.opt.opt.faddr : iph->saddr);
David Miller
maintainerFrom: Joe Perches <[email protected]>
Date: Sun, 8 May 2011 18:14:46 -0700 (PDT)
Quoted 10 lines · David Miller
net/ipv4/icmp.c static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) · line 380
Quoted 8 lines
net/ipv4/icmp.c +3
-0+static struct rtable *icmp_route_lookup (struct net *net, +struct flowi4 *fl4, +struct sk_buff *skb_in,const struct iphdr *iph,__be32 saddr,u8 tos,int type,int code,struct icmp_bxm *param) {[]
Quoted 7 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ memset(&fl4, 0, sizeof(fl4));memset(fl4, 0, sizeof(*fl4));net/ipv4/icmp.c static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) · line 386
Quoted 2 lines
net/ipv4/icmp.c +2
-0+ fl4->daddr = (param->replyopts.opt.opt.srr ? + param->replyopts.opt.opt.faddr : iph->saddr);
Thanks Joe :-/ I'll fix that.