aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-12 00:43:55 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-12 18:08:46 -0500
commit6281dcc94a96bd73017b2baa8fa83925405109ef (patch)
tree8deee4d66d256d10ea25f66520eb96b1fade1545 /include
parent08704bcbf022786532b5f188935ab6619906049f (diff)
net: Make flowi ports AF dependent.
Create two sets of port member accessors, one set prefixed by fl4_* and the other prefixed by fl6_* This will let us to create AF optimal flow instances. It will work because every context in which we access the ports, we have to be fully aware of which AF the flowi is anyways. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/flow.h21
-rw-r--r--include/net/route.h43
-rw-r--r--include/net/xfrm.h18
3 files changed, 46 insertions, 36 deletions
diff --git a/include/net/flow.h b/include/net/flow.h
index 541ac13f245a..f19f41d7dafc 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -89,13 +89,20 @@ struct flowi {
89#define fl4_scope flowi_scope 89#define fl4_scope flowi_scope
90 90
91 union flowi_uli uli_u; 91 union flowi_uli uli_u;
92#define fl_ip_sport uli_u.ports.sport 92#define fl4_sport uli_u.ports.sport
93#define fl_ip_dport uli_u.ports.dport 93#define fl4_dport uli_u.ports.dport
94#define fl_icmp_type uli_u.icmpt.type 94#define fl4_icmp_type uli_u.icmpt.type
95#define fl_icmp_code uli_u.icmpt.code 95#define fl4_icmp_code uli_u.icmpt.code
96#define fl_ipsec_spi uli_u.spi 96#define fl4_ipsec_spi uli_u.spi
97#define fl_mh_type uli_u.mht.type 97#define fl4_mh_type uli_u.mht.type
98#define fl_gre_key uli_u.gre_key 98#define fl4_gre_key uli_u.gre_key
99#define fl6_sport uli_u.ports.sport
100#define fl6_dport uli_u.ports.dport
101#define fl6_icmp_type uli_u.icmpt.type
102#define fl6_icmp_code uli_u.icmpt.code
103#define fl6_ipsec_spi uli_u.spi
104#define fl6_mh_type uli_u.mht.type
105#define fl6_gre_key uli_u.gre_key
99} __attribute__((__aligned__(BITS_PER_LONG/8))); 106} __attribute__((__aligned__(BITS_PER_LONG/8)));
100 107
101#define FLOW_DIR_IN 0 108#define FLOW_DIR_IN 0
diff --git a/include/net/route.h b/include/net/route.h
index 3d814f84abd0..4c207f9fe0cb 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -157,8 +157,8 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock
157 .fl4_src = saddr, 157 .fl4_src = saddr,
158 .fl4_tos = tos, 158 .fl4_tos = tos,
159 .flowi_proto = proto, 159 .flowi_proto = proto,
160 .fl_ip_dport = dport, 160 .fl4_dport = dport,
161 .fl_ip_sport = sport, 161 .fl4_sport = sport,
162 }; 162 };
163 if (sk) 163 if (sk)
164 security_sk_classify_flow(sk, &fl); 164 security_sk_classify_flow(sk, &fl);
@@ -175,7 +175,7 @@ static inline struct rtable *ip_route_output_gre(struct net *net,
175 .fl4_src = saddr, 175 .fl4_src = saddr,
176 .fl4_tos = tos, 176 .fl4_tos = tos,
177 .flowi_proto = IPPROTO_GRE, 177 .flowi_proto = IPPROTO_GRE,
178 .fl_gre_key = gre_key, 178 .fl4_gre_key = gre_key,
179 }; 179 };
180 return ip_route_output_key(net, &fl); 180 return ip_route_output_key(net, &fl);
181} 181}
@@ -228,14 +228,16 @@ static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos,
228 __be16 sport, __be16 dport, 228 __be16 sport, __be16 dport,
229 struct sock *sk, bool can_sleep) 229 struct sock *sk, bool can_sleep)
230{ 230{
231 struct flowi fl = { .flowi_oif = oif, 231 struct flowi fl = {
232 .flowi_mark = sk->sk_mark, 232 .flowi_oif = oif,
233 .fl4_dst = dst, 233 .flowi_mark = sk->sk_mark,
234 .fl4_src = src, 234 .fl4_dst = dst,
235 .fl4_tos = tos, 235 .fl4_src = src,
236 .flowi_proto = protocol, 236 .fl4_tos = tos,
237 .fl_ip_sport = sport, 237 .flowi_proto = protocol,
238 .fl_ip_dport = dport }; 238 .fl4_sport = sport,
239 .fl4_dport = dport,
240 };
239 struct net *net = sock_net(sk); 241 struct net *net = sock_net(sk);
240 struct rtable *rt; 242 struct rtable *rt;
241 243
@@ -264,15 +266,16 @@ static inline struct rtable *ip_route_newports(struct rtable *rt,
264 __be16 dport, struct sock *sk) 266 __be16 dport, struct sock *sk)
265{ 267{
266 if (sport != orig_sport || dport != orig_dport) { 268 if (sport != orig_sport || dport != orig_dport) {
267 struct flowi fl = { .flowi_oif = rt->rt_oif, 269 struct flowi fl = {
268 .flowi_mark = rt->rt_mark, 270 .flowi_oif = rt->rt_oif,
269 .fl4_dst = rt->rt_key_dst, 271 .flowi_mark = rt->rt_mark,
270 .fl4_src = rt->rt_key_src, 272 .fl4_dst = rt->rt_key_dst,
271 .fl4_tos = rt->rt_tos, 273 .fl4_src = rt->rt_key_src,
272 .flowi_proto = protocol, 274 .fl4_tos = rt->rt_tos,
273 .fl_ip_sport = sport, 275 .flowi_proto = protocol,
274 .fl_ip_dport = dport }; 276 .fl4_sport = sport,
275 277 .fl4_dport = dport
278 };
276 if (inet_sk(sk)->transparent) 279 if (inet_sk(sk)->transparent)
277 fl.flowi_flags |= FLOWI_FLAG_ANYSRC; 280 fl.flowi_flags |= FLOWI_FLAG_ANYSRC;
278 if (protocol == IPPROTO_TCP) 281 if (protocol == IPPROTO_TCP)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index d5a12d10a0d4..aa860add570b 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -800,7 +800,7 @@ static inline bool addr_match(const void *token1, const void *token2,
800} 800}
801 801
802static __inline__ 802static __inline__
803__be16 xfrm_flowi_sport(const struct flowi *fl) 803__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli)
804{ 804{
805 __be16 port; 805 __be16 port;
806 switch(fl->flowi_proto) { 806 switch(fl->flowi_proto) {
@@ -808,17 +808,17 @@ __be16 xfrm_flowi_sport(const struct flowi *fl)
808 case IPPROTO_UDP: 808 case IPPROTO_UDP:
809 case IPPROTO_UDPLITE: 809 case IPPROTO_UDPLITE:
810 case IPPROTO_SCTP: 810 case IPPROTO_SCTP:
811 port = fl->fl_ip_sport; 811 port = uli->ports.sport;
812 break; 812 break;
813 case IPPROTO_ICMP: 813 case IPPROTO_ICMP:
814 case IPPROTO_ICMPV6: 814 case IPPROTO_ICMPV6:
815 port = htons(fl->fl_icmp_type); 815 port = htons(uli->icmpt.type);
816 break; 816 break;
817 case IPPROTO_MH: 817 case IPPROTO_MH:
818 port = htons(fl->fl_mh_type); 818 port = htons(uli->mht.type);
819 break; 819 break;
820 case IPPROTO_GRE: 820 case IPPROTO_GRE:
821 port = htons(ntohl(fl->fl_gre_key) >> 16); 821 port = htons(ntohl(uli->gre_key) >> 16);
822 break; 822 break;
823 default: 823 default:
824 port = 0; /*XXX*/ 824 port = 0; /*XXX*/
@@ -827,7 +827,7 @@ __be16 xfrm_flowi_sport(const struct flowi *fl)
827} 827}
828 828
829static __inline__ 829static __inline__
830__be16 xfrm_flowi_dport(const struct flowi *fl) 830__be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
831{ 831{
832 __be16 port; 832 __be16 port;
833 switch(fl->flowi_proto) { 833 switch(fl->flowi_proto) {
@@ -835,14 +835,14 @@ __be16 xfrm_flowi_dport(const struct flowi *fl)
835 case IPPROTO_UDP: 835 case IPPROTO_UDP:
836 case IPPROTO_UDPLITE: 836 case IPPROTO_UDPLITE:
837 case IPPROTO_SCTP: 837 case IPPROTO_SCTP:
838 port = fl->fl_ip_dport; 838 port = uli->ports.dport;
839 break; 839 break;
840 case IPPROTO_ICMP: 840 case IPPROTO_ICMP:
841 case IPPROTO_ICMPV6: 841 case IPPROTO_ICMPV6:
842 port = htons(fl->fl_icmp_code); 842 port = htons(uli->icmpt.code);
843 break; 843 break;
844 case IPPROTO_GRE: 844 case IPPROTO_GRE:
845 port = htons(ntohl(fl->fl_gre_key) & 0xffff); 845 port = htons(ntohl(uli->gre_key) & 0xffff);
846 break; 846 break;
847 default: 847 default:
848 port = 0; /*XXX*/ 848 port = 0; /*XXX*/