diff options
author | David S. Miller <davem@davemloft.net> | 2011-05-08 20:24:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-09 00:24:07 -0400 |
commit | f5fca6086511294653a9e821f8e22f041415ba7b (patch) | |
tree | 1ab025012bf44402e7f816428461d8def54016c1 /net/ipv4 | |
parent | 77968b78242ee25e2a4d759f0fca8dd52df6d479 (diff) |
ipv4: Pass flow key down into ip_append_*().
This way rt->rt_dst accesses are unnecessary.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/icmp.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 18 | ||||
-rw-r--r-- | net/ipv4/raw.c | 2 | ||||
-rw-r--r-- | net/ipv4/udp.c | 12 |
4 files changed, 19 insertions, 15 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index be5cc8d04c00..853a670f6df6 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -297,7 +297,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param, | |||
297 | struct sk_buff *skb; | 297 | struct sk_buff *skb; |
298 | 298 | ||
299 | sk = icmp_sk(dev_net((*rt)->dst.dev)); | 299 | sk = icmp_sk(dev_net((*rt)->dst.dev)); |
300 | if (ip_append_data(sk, icmp_glue_bits, icmp_param, | 300 | if (ip_append_data(sk, fl4, icmp_glue_bits, icmp_param, |
301 | icmp_param->data_len+icmp_param->head_len, | 301 | icmp_param->data_len+icmp_param->head_len, |
302 | icmp_param->head_len, | 302 | icmp_param->head_len, |
303 | ipc, rt, MSG_DONTWAIT) < 0) { | 303 | ipc, rt, MSG_DONTWAIT) < 0) { |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index dca637b9d8ae..cd89d22902a9 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -776,7 +776,9 @@ static inline int ip_ufo_append_data(struct sock *sk, | |||
776 | (length - transhdrlen)); | 776 | (length - transhdrlen)); |
777 | } | 777 | } |
778 | 778 | ||
779 | static int __ip_append_data(struct sock *sk, struct sk_buff_head *queue, | 779 | static int __ip_append_data(struct sock *sk, |
780 | struct flowi4 *fl4, | ||
781 | struct sk_buff_head *queue, | ||
780 | struct inet_cork *cork, | 782 | struct inet_cork *cork, |
781 | int getfrag(void *from, char *to, int offset, | 783 | int getfrag(void *from, char *to, int offset, |
782 | int len, int odd, struct sk_buff *skb), | 784 | int len, int odd, struct sk_buff *skb), |
@@ -808,7 +810,7 @@ static int __ip_append_data(struct sock *sk, struct sk_buff_head *queue, | |||
808 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; | 810 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; |
809 | 811 | ||
810 | if (cork->length + length > 0xFFFF - fragheaderlen) { | 812 | if (cork->length + length > 0xFFFF - fragheaderlen) { |
811 | ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport, | 813 | ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport, |
812 | mtu-exthdrlen); | 814 | mtu-exthdrlen); |
813 | return -EMSGSIZE; | 815 | return -EMSGSIZE; |
814 | } | 816 | } |
@@ -1083,7 +1085,7 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork, | |||
1083 | * | 1085 | * |
1084 | * LATER: length must be adjusted by pad at tail, when it is required. | 1086 | * LATER: length must be adjusted by pad at tail, when it is required. |
1085 | */ | 1087 | */ |
1086 | int ip_append_data(struct sock *sk, | 1088 | int ip_append_data(struct sock *sk, struct flowi4 *fl4, |
1087 | int getfrag(void *from, char *to, int offset, int len, | 1089 | int getfrag(void *from, char *to, int offset, int len, |
1088 | int odd, struct sk_buff *skb), | 1090 | int odd, struct sk_buff *skb), |
1089 | void *from, int length, int transhdrlen, | 1091 | void *from, int length, int transhdrlen, |
@@ -1104,11 +1106,11 @@ int ip_append_data(struct sock *sk, | |||
1104 | transhdrlen = 0; | 1106 | transhdrlen = 0; |
1105 | } | 1107 | } |
1106 | 1108 | ||
1107 | return __ip_append_data(sk, &sk->sk_write_queue, &inet->cork.base, getfrag, | 1109 | return __ip_append_data(sk, fl4, &sk->sk_write_queue, &inet->cork.base, getfrag, |
1108 | from, length, transhdrlen, flags); | 1110 | from, length, transhdrlen, flags); |
1109 | } | 1111 | } |
1110 | 1112 | ||
1111 | ssize_t ip_append_page(struct sock *sk, struct page *page, | 1113 | ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, |
1112 | int offset, size_t size, int flags) | 1114 | int offset, size_t size, int flags) |
1113 | { | 1115 | { |
1114 | struct inet_sock *inet = inet_sk(sk); | 1116 | struct inet_sock *inet = inet_sk(sk); |
@@ -1146,7 +1148,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page, | |||
1146 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; | 1148 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; |
1147 | 1149 | ||
1148 | if (cork->length + size > 0xFFFF - fragheaderlen) { | 1150 | if (cork->length + size > 0xFFFF - fragheaderlen) { |
1149 | ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inet_dport, mtu); | 1151 | ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport, mtu); |
1150 | return -EMSGSIZE; | 1152 | return -EMSGSIZE; |
1151 | } | 1153 | } |
1152 | 1154 | ||
@@ -1427,7 +1429,7 @@ struct sk_buff *ip_make_skb(struct sock *sk, | |||
1427 | if (err) | 1429 | if (err) |
1428 | return ERR_PTR(err); | 1430 | return ERR_PTR(err); |
1429 | 1431 | ||
1430 | err = __ip_append_data(sk, &queue, &cork, getfrag, | 1432 | err = __ip_append_data(sk, fl4, &queue, &cork, getfrag, |
1431 | from, length, transhdrlen, flags); | 1433 | from, length, transhdrlen, flags); |
1432 | if (err) { | 1434 | if (err) { |
1433 | __ip_flush_pending_frames(sk, &queue, &cork); | 1435 | __ip_flush_pending_frames(sk, &queue, &cork); |
@@ -1503,7 +1505,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar | |||
1503 | sk->sk_priority = skb->priority; | 1505 | sk->sk_priority = skb->priority; |
1504 | sk->sk_protocol = ip_hdr(skb)->protocol; | 1506 | sk->sk_protocol = ip_hdr(skb)->protocol; |
1505 | sk->sk_bound_dev_if = arg->bound_dev_if; | 1507 | sk->sk_bound_dev_if = arg->bound_dev_if; |
1506 | ip_append_data(sk, ip_reply_glue_bits, arg->iov->iov_base, len, 0, | 1508 | ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, len, 0, |
1507 | &ipc, &rt, MSG_DONTWAIT); | 1509 | &ipc, &rt, MSG_DONTWAIT); |
1508 | if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { | 1510 | if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { |
1509 | if (arg->csumoffset >= 0) | 1511 | if (arg->csumoffset >= 0) |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 6fee91f656a9..11e1780455f2 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -595,7 +595,7 @@ back_from_confirm: | |||
595 | if (!ipc.addr) | 595 | if (!ipc.addr) |
596 | ipc.addr = fl4.daddr; | 596 | ipc.addr = fl4.daddr; |
597 | lock_sock(sk); | 597 | lock_sock(sk); |
598 | err = ip_append_data(sk, ip_generic_getfrag, | 598 | err = ip_append_data(sk, &fl4, ip_generic_getfrag, |
599 | msg->msg_iov, len, 0, | 599 | msg->msg_iov, len, 0, |
600 | &ipc, &rt, msg->msg_flags); | 600 | &ipc, &rt, msg->msg_flags); |
601 | if (err) | 601 | if (err) |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 006e2ccd6cc2..66341a3c8d36 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -822,6 +822,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
822 | 822 | ||
823 | getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag; | 823 | getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag; |
824 | 824 | ||
825 | fl4 = &inet->cork.fl.u.ip4; | ||
825 | if (up->pending) { | 826 | if (up->pending) { |
826 | /* | 827 | /* |
827 | * There are pending frames. | 828 | * There are pending frames. |
@@ -920,7 +921,6 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
920 | if (connected) | 921 | if (connected) |
921 | rt = (struct rtable *)sk_dst_check(sk, 0); | 922 | rt = (struct rtable *)sk_dst_check(sk, 0); |
922 | 923 | ||
923 | fl4 = &inet->cork.fl.u.ip4; | ||
924 | if (rt == NULL) { | 924 | if (rt == NULL) { |
925 | struct net *net = sock_net(sk); | 925 | struct net *net = sock_net(sk); |
926 | 926 | ||
@@ -989,9 +989,9 @@ back_from_confirm: | |||
989 | 989 | ||
990 | do_append_data: | 990 | do_append_data: |
991 | up->len += ulen; | 991 | up->len += ulen; |
992 | err = ip_append_data(sk, getfrag, msg->msg_iov, ulen, | 992 | err = ip_append_data(sk, fl4, getfrag, msg->msg_iov, ulen, |
993 | sizeof(struct udphdr), &ipc, &rt, | 993 | sizeof(struct udphdr), &ipc, &rt, |
994 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); | 994 | corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); |
995 | if (err) | 995 | if (err) |
996 | udp_flush_pending_frames(sk); | 996 | udp_flush_pending_frames(sk); |
997 | else if (!corkreq) | 997 | else if (!corkreq) |
@@ -1031,6 +1031,7 @@ EXPORT_SYMBOL(udp_sendmsg); | |||
1031 | int udp_sendpage(struct sock *sk, struct page *page, int offset, | 1031 | int udp_sendpage(struct sock *sk, struct page *page, int offset, |
1032 | size_t size, int flags) | 1032 | size_t size, int flags) |
1033 | { | 1033 | { |
1034 | struct inet_sock *inet = inet_sk(sk); | ||
1034 | struct udp_sock *up = udp_sk(sk); | 1035 | struct udp_sock *up = udp_sk(sk); |
1035 | int ret; | 1036 | int ret; |
1036 | 1037 | ||
@@ -1055,7 +1056,8 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, | |||
1055 | return -EINVAL; | 1056 | return -EINVAL; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | ret = ip_append_page(sk, page, offset, size, flags); | 1059 | ret = ip_append_page(sk, &inet->cork.fl.u.ip4, |
1060 | page, offset, size, flags); | ||
1059 | if (ret == -EOPNOTSUPP) { | 1061 | if (ret == -EOPNOTSUPP) { |
1060 | release_sock(sk); | 1062 | release_sock(sk); |
1061 | return sock_no_sendpage(sk->sk_socket, page, offset, | 1063 | return sock_no_sendpage(sk->sk_socket, page, offset, |