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>
This commit is contained in:
committed by
David S. Miller
parent
d92222e27f
commit
20c59de2e6
@ -185,7 +185,7 @@ int inet6_csk_xmit(struct sk_buff *skb)
|
||||
struct ipv6_pinfo *np = inet6_sk(sk);
|
||||
struct flowi fl;
|
||||
struct dst_entry *dst;
|
||||
struct in6_addr *final_p = NULL, final;
|
||||
struct in6_addr *final_p, final;
|
||||
|
||||
memset(&fl, 0, sizeof(fl));
|
||||
fl.proto = sk->sk_protocol;
|
||||
@ -199,12 +199,7 @@ int inet6_csk_xmit(struct sk_buff *skb)
|
||||
fl.fl_ip_dport = inet->inet_dport;
|
||||
security_sk_classify_flow(sk, &fl);
|
||||
|
||||
if (np->opt && np->opt->srcrt) {
|
||||
struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
|
||||
ipv6_addr_copy(&final, &fl.fl6_dst);
|
||||
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
|
||||
final_p = &final;
|
||||
}
|
||||
final_p = fl6_update_dst(&fl, np->opt, &final);
|
||||
|
||||
dst = __inet6_csk_dst_check(sk, np->dst_cookie);
|
||||
|
||||
|
Reference in New Issue
Block a user