diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-12 02:42:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-12 18:08:52 -0500 |
commit | 7e1dc7b6f709dfc1a9ab4b320dbe723f45992693 (patch) | |
tree | db3a0ae07fb469c7f809a448bc39563f98edfec5 /net/ipv4 | |
parent | 2032656e76b5355151effdff14de4a1a58643915 (diff) |
net: Use flowi4 and flowi6 in xfrm layer.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/xfrm4_policy.c | 46 | ||||
-rw-r--r-- | net/ipv4/xfrm4_state.c | 14 |
2 files changed, 32 insertions, 28 deletions
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index b111f468fa29..30b312c577bc 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -56,7 +56,7 @@ static int xfrm4_get_saddr(struct net *net, | |||
56 | 56 | ||
57 | static int xfrm4_get_tos(const struct flowi *fl) | 57 | static int xfrm4_get_tos(const struct flowi *fl) |
58 | { | 58 | { |
59 | return IPTOS_RT_MASK & fl->fl4_tos; /* Strip ECN bits */ | 59 | return IPTOS_RT_MASK & fl->u.ip4.flowi4_tos; /* Strip ECN bits */ |
60 | } | 60 | } |
61 | 61 | ||
62 | static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst, | 62 | static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst, |
@@ -69,13 +69,14 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, | |||
69 | const struct flowi *fl) | 69 | const struct flowi *fl) |
70 | { | 70 | { |
71 | struct rtable *rt = (struct rtable *)xdst->route; | 71 | struct rtable *rt = (struct rtable *)xdst->route; |
72 | const struct flowi4 *fl4 = &fl->u.ip4; | ||
72 | 73 | ||
73 | rt->rt_key_dst = fl->fl4_dst; | 74 | rt->rt_key_dst = fl4->daddr; |
74 | rt->rt_key_src = fl->fl4_src; | 75 | rt->rt_key_src = fl4->saddr; |
75 | rt->rt_tos = fl->fl4_tos; | 76 | rt->rt_tos = fl4->flowi4_tos; |
76 | rt->rt_iif = fl->flowi_iif; | 77 | rt->rt_iif = fl4->flowi4_iif; |
77 | rt->rt_oif = fl->flowi_oif; | 78 | rt->rt_oif = fl4->flowi4_oif; |
78 | rt->rt_mark = fl->flowi_mark; | 79 | rt->rt_mark = fl4->flowi4_mark; |
79 | 80 | ||
80 | xdst->u.dst.dev = dev; | 81 | xdst->u.dst.dev = dev; |
81 | dev_hold(dev); | 82 | dev_hold(dev); |
@@ -102,9 +103,10 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
102 | { | 103 | { |
103 | struct iphdr *iph = ip_hdr(skb); | 104 | struct iphdr *iph = ip_hdr(skb); |
104 | u8 *xprth = skb_network_header(skb) + iph->ihl * 4; | 105 | u8 *xprth = skb_network_header(skb) + iph->ihl * 4; |
106 | struct flowi4 *fl4 = &fl->u.ip4; | ||
105 | 107 | ||
106 | memset(fl, 0, sizeof(struct flowi)); | 108 | memset(fl4, 0, sizeof(struct flowi4)); |
107 | fl->flowi_mark = skb->mark; | 109 | fl4->flowi4_mark = skb->mark; |
108 | 110 | ||
109 | if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { | 111 | if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { |
110 | switch (iph->protocol) { | 112 | switch (iph->protocol) { |
@@ -117,8 +119,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
117 | pskb_may_pull(skb, xprth + 4 - skb->data)) { | 119 | pskb_may_pull(skb, xprth + 4 - skb->data)) { |
118 | __be16 *ports = (__be16 *)xprth; | 120 | __be16 *ports = (__be16 *)xprth; |
119 | 121 | ||
120 | fl->fl4_sport = ports[!!reverse]; | 122 | fl4->uli.ports.sport = ports[!!reverse]; |
121 | fl->fl4_dport = ports[!reverse]; | 123 | fl4->uli.ports.dport = ports[!reverse]; |
122 | } | 124 | } |
123 | break; | 125 | break; |
124 | 126 | ||
@@ -126,8 +128,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
126 | if (pskb_may_pull(skb, xprth + 2 - skb->data)) { | 128 | if (pskb_may_pull(skb, xprth + 2 - skb->data)) { |
127 | u8 *icmp = xprth; | 129 | u8 *icmp = xprth; |
128 | 130 | ||
129 | fl->fl4_icmp_type = icmp[0]; | 131 | fl4->uli.icmpt.type = icmp[0]; |
130 | fl->fl4_icmp_code = icmp[1]; | 132 | fl4->uli.icmpt.code = icmp[1]; |
131 | } | 133 | } |
132 | break; | 134 | break; |
133 | 135 | ||
@@ -135,7 +137,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
135 | if (pskb_may_pull(skb, xprth + 4 - skb->data)) { | 137 | if (pskb_may_pull(skb, xprth + 4 - skb->data)) { |
136 | __be32 *ehdr = (__be32 *)xprth; | 138 | __be32 *ehdr = (__be32 *)xprth; |
137 | 139 | ||
138 | fl->fl4_ipsec_spi = ehdr[0]; | 140 | fl4->uli.spi = ehdr[0]; |
139 | } | 141 | } |
140 | break; | 142 | break; |
141 | 143 | ||
@@ -143,7 +145,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
143 | if (pskb_may_pull(skb, xprth + 8 - skb->data)) { | 145 | if (pskb_may_pull(skb, xprth + 8 - skb->data)) { |
144 | __be32 *ah_hdr = (__be32*)xprth; | 146 | __be32 *ah_hdr = (__be32*)xprth; |
145 | 147 | ||
146 | fl->fl4_ipsec_spi = ah_hdr[1]; | 148 | fl4->uli.spi = ah_hdr[1]; |
147 | } | 149 | } |
148 | break; | 150 | break; |
149 | 151 | ||
@@ -151,7 +153,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
151 | if (pskb_may_pull(skb, xprth + 4 - skb->data)) { | 153 | if (pskb_may_pull(skb, xprth + 4 - skb->data)) { |
152 | __be16 *ipcomp_hdr = (__be16 *)xprth; | 154 | __be16 *ipcomp_hdr = (__be16 *)xprth; |
153 | 155 | ||
154 | fl->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1])); | 156 | fl4->uli.spi = htonl(ntohs(ipcomp_hdr[1])); |
155 | } | 157 | } |
156 | break; | 158 | break; |
157 | 159 | ||
@@ -163,20 +165,20 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) | |||
163 | if (greflags[0] & GRE_KEY) { | 165 | if (greflags[0] & GRE_KEY) { |
164 | if (greflags[0] & GRE_CSUM) | 166 | if (greflags[0] & GRE_CSUM) |
165 | gre_hdr++; | 167 | gre_hdr++; |
166 | fl->fl4_gre_key = gre_hdr[1]; | 168 | fl4->uli.gre_key = gre_hdr[1]; |
167 | } | 169 | } |
168 | } | 170 | } |
169 | break; | 171 | break; |
170 | 172 | ||
171 | default: | 173 | default: |
172 | fl->fl4_ipsec_spi = 0; | 174 | fl4->uli.spi = 0; |
173 | break; | 175 | break; |
174 | } | 176 | } |
175 | } | 177 | } |
176 | fl->flowi_proto = iph->protocol; | 178 | fl4->flowi4_proto = iph->protocol; |
177 | fl->fl4_dst = reverse ? iph->saddr : iph->daddr; | 179 | fl4->daddr = reverse ? iph->saddr : iph->daddr; |
178 | fl->fl4_src = reverse ? iph->daddr : iph->saddr; | 180 | fl4->saddr = reverse ? iph->daddr : iph->saddr; |
179 | fl->fl4_tos = iph->tos; | 181 | fl4->flowi4_tos = iph->tos; |
180 | } | 182 | } |
181 | 183 | ||
182 | static inline int xfrm4_garbage_collect(struct dst_ops *ops) | 184 | static inline int xfrm4_garbage_collect(struct dst_ops *ops) |
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c index d8d541954532..1717c64628d1 100644 --- a/net/ipv4/xfrm4_state.c +++ b/net/ipv4/xfrm4_state.c | |||
@@ -23,17 +23,19 @@ static int xfrm4_init_flags(struct xfrm_state *x) | |||
23 | static void | 23 | static void |
24 | __xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl) | 24 | __xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl) |
25 | { | 25 | { |
26 | sel->daddr.a4 = fl->fl4_dst; | 26 | const struct flowi4 *fl4 = &fl->u.ip4; |
27 | sel->saddr.a4 = fl->fl4_src; | 27 | |
28 | sel->dport = xfrm_flowi_dport(fl, &fl->u.ip4.uli); | 28 | sel->daddr.a4 = fl4->daddr; |
29 | sel->saddr.a4 = fl4->saddr; | ||
30 | sel->dport = xfrm_flowi_dport(fl, &fl4->uli); | ||
29 | sel->dport_mask = htons(0xffff); | 31 | sel->dport_mask = htons(0xffff); |
30 | sel->sport = xfrm_flowi_sport(fl, &fl->u.ip4.uli); | 32 | sel->sport = xfrm_flowi_sport(fl, &fl4->uli); |
31 | sel->sport_mask = htons(0xffff); | 33 | sel->sport_mask = htons(0xffff); |
32 | sel->family = AF_INET; | 34 | sel->family = AF_INET; |
33 | sel->prefixlen_d = 32; | 35 | sel->prefixlen_d = 32; |
34 | sel->prefixlen_s = 32; | 36 | sel->prefixlen_s = 32; |
35 | sel->proto = fl->flowi_proto; | 37 | sel->proto = fl4->flowi4_proto; |
36 | sel->ifindex = fl->flowi_oif; | 38 | sel->ifindex = fl4->flowi4_oif; |
37 | } | 39 | } |
38 | 40 | ||
39 | static void | 41 | static void |