diff options
author | Arnaud Ebalard <arno@natisbad.org> | 2010-06-01 17:35:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-02 10:08:31 -0400 |
commit | 20c59de2e6b6bc74bbf714dcd4e720afe8d516cf (patch) | |
tree | 45e5c62e286368f8259b844cb7cf796d19066fb0 /net/ipv6/udp.c | |
parent | d92222e27fdc98d73df25f3d49fb1ff3a3369bec (diff) |
ipv6: Refactor update of IPv6 flowi destination address for srcrt (RH) option
There are more than a dozen occurrences of following code in the
IPv6 stack:
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
ipv6_addr_copy(&final, &fl.fl6_dst);
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
final_p = &final;
}
Replace those with a helper. Note that the helper overrides final_p
in all cases. This is ok as final_p was previously initialized to
NULL when declared.
Signed-off-by: Arnaud Ebalard <arno@natisbad.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r-- | net/ipv6/udp.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 3048f906c042..4aea57dec75f 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -929,7 +929,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
929 | struct inet_sock *inet = inet_sk(sk); | 929 | struct inet_sock *inet = inet_sk(sk); |
930 | struct ipv6_pinfo *np = inet6_sk(sk); | 930 | struct ipv6_pinfo *np = inet6_sk(sk); |
931 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name; | 931 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name; |
932 | struct in6_addr *daddr, *final_p = NULL, final; | 932 | struct in6_addr *daddr, *final_p, final; |
933 | struct ipv6_txoptions *opt = NULL; | 933 | struct ipv6_txoptions *opt = NULL; |
934 | struct ip6_flowlabel *flowlabel = NULL; | 934 | struct ip6_flowlabel *flowlabel = NULL; |
935 | struct flowi fl; | 935 | struct flowi fl; |
@@ -1099,14 +1099,9 @@ do_udp_sendmsg: | |||
1099 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); | 1099 | ipv6_addr_copy(&fl.fl6_src, &np->saddr); |
1100 | fl.fl_ip_sport = inet->inet_sport; | 1100 | fl.fl_ip_sport = inet->inet_sport; |
1101 | 1101 | ||
1102 | /* merge ip6_build_xmit from ip6_output */ | 1102 | final_p = fl6_update_dst(&fl, opt, &final); |
1103 | if (opt && opt->srcrt) { | 1103 | if (final_p) |
1104 | struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; | ||
1105 | ipv6_addr_copy(&final, &fl.fl6_dst); | ||
1106 | ipv6_addr_copy(&fl.fl6_dst, rt0->addr); | ||
1107 | final_p = &final; | ||
1108 | connected = 0; | 1104 | connected = 0; |
1109 | } | ||
1110 | 1105 | ||
1111 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) { | 1106 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) { |
1112 | fl.oif = np->mcast_oif; | 1107 | fl.oif = np->mcast_oif; |