提交 6281dcc9 编写于 作者: D David S. Miller

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: NDavid S. Miller <davem@davemloft.net>
上级 08704bcb
......@@ -89,13 +89,20 @@ struct flowi {
#define fl4_scope flowi_scope
union flowi_uli uli_u;
#define fl_ip_sport uli_u.ports.sport
#define fl_ip_dport uli_u.ports.dport
#define fl_icmp_type uli_u.icmpt.type
#define fl_icmp_code uli_u.icmpt.code
#define fl_ipsec_spi uli_u.spi
#define fl_mh_type uli_u.mht.type
#define fl_gre_key uli_u.gre_key
#define fl4_sport uli_u.ports.sport
#define fl4_dport uli_u.ports.dport
#define fl4_icmp_type uli_u.icmpt.type
#define fl4_icmp_code uli_u.icmpt.code
#define fl4_ipsec_spi uli_u.spi
#define fl4_mh_type uli_u.mht.type
#define fl4_gre_key uli_u.gre_key
#define fl6_sport uli_u.ports.sport
#define fl6_dport uli_u.ports.dport
#define fl6_icmp_type uli_u.icmpt.type
#define fl6_icmp_code uli_u.icmpt.code
#define fl6_ipsec_spi uli_u.spi
#define fl6_mh_type uli_u.mht.type
#define fl6_gre_key uli_u.gre_key
} __attribute__((__aligned__(BITS_PER_LONG/8)));
#define FLOW_DIR_IN 0
......
......@@ -157,8 +157,8 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock
.fl4_src = saddr,
.fl4_tos = tos,
.flowi_proto = proto,
.fl_ip_dport = dport,
.fl_ip_sport = sport,
.fl4_dport = dport,
.fl4_sport = sport,
};
if (sk)
security_sk_classify_flow(sk, &fl);
......@@ -175,7 +175,7 @@ static inline struct rtable *ip_route_output_gre(struct net *net,
.fl4_src = saddr,
.fl4_tos = tos,
.flowi_proto = IPPROTO_GRE,
.fl_gre_key = gre_key,
.fl4_gre_key = gre_key,
};
return ip_route_output_key(net, &fl);
}
......@@ -228,14 +228,16 @@ static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos,
__be16 sport, __be16 dport,
struct sock *sk, bool can_sleep)
{
struct flowi fl = { .flowi_oif = oif,
.flowi_mark = sk->sk_mark,
.fl4_dst = dst,
.fl4_src = src,
.fl4_tos = tos,
.flowi_proto = protocol,
.fl_ip_sport = sport,
.fl_ip_dport = dport };
struct flowi fl = {
.flowi_oif = oif,
.flowi_mark = sk->sk_mark,
.fl4_dst = dst,
.fl4_src = src,
.fl4_tos = tos,
.flowi_proto = protocol,
.fl4_sport = sport,
.fl4_dport = dport,
};
struct net *net = sock_net(sk);
struct rtable *rt;
......@@ -264,15 +266,16 @@ static inline struct rtable *ip_route_newports(struct rtable *rt,
__be16 dport, struct sock *sk)
{
if (sport != orig_sport || dport != orig_dport) {
struct flowi fl = { .flowi_oif = rt->rt_oif,
.flowi_mark = rt->rt_mark,
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.flowi_proto = protocol,
.fl_ip_sport = sport,
.fl_ip_dport = dport };
struct flowi fl = {
.flowi_oif = rt->rt_oif,
.flowi_mark = rt->rt_mark,
.fl4_dst = rt->rt_key_dst,
.fl4_src = rt->rt_key_src,
.fl4_tos = rt->rt_tos,
.flowi_proto = protocol,
.fl4_sport = sport,
.fl4_dport = dport
};
if (inet_sk(sk)->transparent)
fl.flowi_flags |= FLOWI_FLAG_ANYSRC;
if (protocol == IPPROTO_TCP)
......
......@@ -800,7 +800,7 @@ static inline bool addr_match(const void *token1, const void *token2,
}
static __inline__
__be16 xfrm_flowi_sport(const struct flowi *fl)
__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli)
{
__be16 port;
switch(fl->flowi_proto) {
......@@ -808,17 +808,17 @@ __be16 xfrm_flowi_sport(const struct flowi *fl)
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
case IPPROTO_SCTP:
port = fl->fl_ip_sport;
port = uli->ports.sport;
break;
case IPPROTO_ICMP:
case IPPROTO_ICMPV6:
port = htons(fl->fl_icmp_type);
port = htons(uli->icmpt.type);
break;
case IPPROTO_MH:
port = htons(fl->fl_mh_type);
port = htons(uli->mht.type);
break;
case IPPROTO_GRE:
port = htons(ntohl(fl->fl_gre_key) >> 16);
port = htons(ntohl(uli->gre_key) >> 16);
break;
default:
port = 0; /*XXX*/
......@@ -827,7 +827,7 @@ __be16 xfrm_flowi_sport(const struct flowi *fl)
}
static __inline__
__be16 xfrm_flowi_dport(const struct flowi *fl)
__be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
{
__be16 port;
switch(fl->flowi_proto) {
......@@ -835,14 +835,14 @@ __be16 xfrm_flowi_dport(const struct flowi *fl)
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
case IPPROTO_SCTP:
port = fl->fl_ip_dport;
port = uli->ports.dport;
break;
case IPPROTO_ICMP:
case IPPROTO_ICMPV6:
port = htons(fl->fl_icmp_code);
port = htons(uli->icmpt.code);
break;
case IPPROTO_GRE:
port = htons(ntohl(fl->fl_gre_key) & 0xffff);
port = htons(ntohl(uli->gre_key) & 0xffff);
break;
default:
port = 0; /*XXX*/
......
......@@ -471,8 +471,8 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
.fl4_src = ip_hdr(skb)->daddr,
.fl4_tos = RT_CONN_FLAGS(sk),
.flowi_proto = sk->sk_protocol,
.fl_ip_sport = dccp_hdr(skb)->dccph_dport,
.fl_ip_dport = dccp_hdr(skb)->dccph_sport,
.fl4_sport = dccp_hdr(skb)->dccph_dport,
.fl4_dport = dccp_hdr(skb)->dccph_sport,
};
security_skb_classify_flow(skb, &fl);
......
......@@ -158,8 +158,8 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fl_ip_dport = inet->inet_dport;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = inet->inet_dport;
fl.fl6_sport = inet->inet_sport;
security_sk_classify_flow(sk, &fl);
dst = ip6_dst_lookup_flow(sk, &fl, NULL, false);
......@@ -253,8 +253,8 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
fl.fl6_flowlabel = 0;
fl.flowi_oif = ireq6->iif;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_rsk(req)->loc_port;
fl.fl6_dport = inet_rsk(req)->rmt_port;
fl.fl6_sport = inet_rsk(req)->loc_port;
security_req_classify_flow(req, &fl);
opt = np->opt;
......@@ -323,8 +323,8 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
fl.flowi_proto = IPPROTO_DCCP;
fl.flowi_oif = inet6_iif(rxskb);
fl.fl_ip_dport = dccp_hdr(skb)->dccph_dport;
fl.fl_ip_sport = dccp_hdr(skb)->dccph_sport;
fl.fl6_dport = dccp_hdr(skb)->dccph_dport;
fl.fl6_sport = dccp_hdr(skb)->dccph_sport;
security_skb_classify_flow(rxskb, &fl);
/* sk = NULL, but it is safe for now. RST socket required. */
......@@ -535,8 +535,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
final_p = fl6_update_dst(&fl, opt, &final);
ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_rsk(req)->loc_port;
fl.fl6_dport = inet_rsk(req)->rmt_port;
fl.fl6_sport = inet_rsk(req)->loc_port;
security_sk_classify_flow(sk, &fl);
dst = ip6_dst_lookup_flow(sk, &fl, final_p, false);
......@@ -957,8 +957,8 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fl_ip_dport = usin->sin6_port;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = usin->sin6_port;
fl.fl6_sport = inet->inet_sport;
security_sk_classify_flow(sk, &fl);
final_p = fl6_update_dst(&fl, np->opt, &final);
......
......@@ -384,8 +384,8 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in,
.fl4_src = saddr,
.fl4_tos = RT_TOS(tos),
.flowi_proto = IPPROTO_ICMP,
.fl_icmp_type = type,
.fl_icmp_code = code,
.fl4_icmp_type = type,
.fl4_icmp_code = code,
};
struct rtable *rt, *rt2;
int err;
......
......@@ -365,8 +365,8 @@ struct dst_entry *inet_csk_route_req(struct sock *sk,
.fl4_tos = RT_CONN_FLAGS(sk),
.flowi_proto = sk->sk_protocol,
.flowi_flags = inet_sk_flowi_flags(sk),
.fl_ip_sport = inet_sk(sk)->inet_sport,
.fl_ip_dport = ireq->rmt_port,
.fl4_sport = inet_sk(sk)->inet_sport,
.fl4_dport = ireq->rmt_port,
};
struct net *net = sock_net(sk);
......
......@@ -1479,8 +1479,8 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
.fl4_dst = daddr,
.fl4_src = rt->rt_spec_dst,
.fl4_tos = RT_TOS(ip_hdr(skb)->tos),
.fl_ip_sport = tcp_hdr(skb)->dest,
.fl_ip_dport = tcp_hdr(skb)->source,
.fl4_sport = tcp_hdr(skb)->dest,
.fl4_dport = tcp_hdr(skb)->source,
.flowi_proto = sk->sk_protocol,
.flowi_flags = ip_reply_arg_flowi_flags(arg),
};
......
......@@ -55,7 +55,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
t->dst.protonum == IPPROTO_UDPLITE ||
t->dst.protonum == IPPROTO_DCCP ||
t->dst.protonum == IPPROTO_SCTP)
fl->fl_ip_dport = t->dst.u.tcp.port;
fl->fl4_dport = t->dst.u.tcp.port;
}
statusbit ^= IPS_NAT_MASK;
......@@ -67,7 +67,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
t->dst.protonum == IPPROTO_UDPLITE ||
t->dst.protonum == IPPROTO_DCCP ||
t->dst.protonum == IPPROTO_SCTP)
fl->fl_ip_sport = t->src.u.tcp.port;
fl->fl4_sport = t->src.u.tcp.port;
}
}
#endif
......
......@@ -433,8 +433,8 @@ static int raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
code = iov->iov_base;
if (type && code) {
if (get_user(fl->fl_icmp_type, type) ||
get_user(fl->fl_icmp_code, code))
if (get_user(fl->fl4_icmp_type, type) ||
get_user(fl->fl4_icmp_code, code))
return -EFAULT;
probed = 1;
}
......
......@@ -353,8 +353,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
.fl4_tos = RT_CONN_FLAGS(sk),
.flowi_proto = IPPROTO_TCP,
.flowi_flags = inet_sk_flowi_flags(sk),
.fl_ip_sport = th->dest,
.fl_ip_dport = th->source,
.fl4_sport = th->dest,
.fl4_dport = th->source,
};
security_req_classify_flow(req, &fl);
rt = ip_route_output_key(sock_net(sk), &fl);
......
......@@ -778,7 +778,7 @@ static int udp_push_pending_frames(struct sock *sk)
if (!skb)
goto out;
err = udp_send_skb(skb, fl->fl4_dst, fl->fl_ip_dport);
err = udp_send_skb(skb, fl->fl4_dst, fl->fl4_dport);
out:
up->len = 0;
......@@ -917,8 +917,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.flowi_proto = sk->sk_protocol,
.flowi_flags = (inet_sk_flowi_flags(sk) |
FLOWI_FLAG_CAN_SLEEP),
.fl_ip_sport = inet->inet_sport,
.fl_ip_dport = dport,
.fl4_sport = inet->inet_sport,
.fl4_dport = dport,
};
struct net *net = sock_net(sk);
......@@ -973,9 +973,9 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
* Now cork the socket to pend data.
*/
inet->cork.fl.fl4_dst = daddr;
inet->cork.fl.fl_ip_dport = dport;
inet->cork.fl.fl4_dport = dport;
inet->cork.fl.fl4_src = saddr;
inet->cork.fl.fl_ip_sport = inet->inet_sport;
inet->cork.fl.fl4_sport = inet->inet_sport;
up->pending = AF_INET;
do_append_data:
......
......@@ -117,8 +117,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be16 *ports = (__be16 *)xprth;
fl->fl_ip_sport = ports[!!reverse];
fl->fl_ip_dport = ports[!reverse];
fl->fl4_sport = ports[!!reverse];
fl->fl4_dport = ports[!reverse];
}
break;
......@@ -126,8 +126,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 2 - skb->data)) {
u8 *icmp = xprth;
fl->fl_icmp_type = icmp[0];
fl->fl_icmp_code = icmp[1];
fl->fl4_icmp_type = icmp[0];
fl->fl4_icmp_code = icmp[1];
}
break;
......@@ -135,7 +135,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be32 *ehdr = (__be32 *)xprth;
fl->fl_ipsec_spi = ehdr[0];
fl->fl4_ipsec_spi = ehdr[0];
}
break;
......@@ -143,7 +143,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 8 - skb->data)) {
__be32 *ah_hdr = (__be32*)xprth;
fl->fl_ipsec_spi = ah_hdr[1];
fl->fl4_ipsec_spi = ah_hdr[1];
}
break;
......@@ -151,7 +151,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be16 *ipcomp_hdr = (__be16 *)xprth;
fl->fl_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
fl->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
}
break;
......@@ -163,13 +163,13 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (greflags[0] & GRE_KEY) {
if (greflags[0] & GRE_CSUM)
gre_hdr++;
fl->fl_gre_key = gre_hdr[1];
fl->fl4_gre_key = gre_hdr[1];
}
}
break;
default:
fl->fl_ipsec_spi = 0;
fl->fl4_ipsec_spi = 0;
break;
}
}
......
......@@ -25,9 +25,9 @@ __xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
{
sel->daddr.a4 = fl->fl4_dst;
sel->saddr.a4 = fl->fl4_src;
sel->dport = xfrm_flowi_dport(fl);
sel->dport = xfrm_flowi_dport(fl, &fl->uli_u);
sel->dport_mask = htons(0xffff);
sel->sport = xfrm_flowi_sport(fl);
sel->sport = xfrm_flowi_sport(fl, &fl->uli_u);
sel->sport_mask = htons(0xffff);
sel->family = AF_INET;
sel->prefixlen_d = 32;
......
......@@ -661,8 +661,8 @@ int inet6_sk_rebuild_header(struct sock *sk)
fl.fl6_flowlabel = np->flow_label;
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet->inet_dport;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = inet->inet_dport;
fl.fl6_sport = inet->inet_sport;
security_sk_classify_flow(sk, &fl);
final_p = fl6_update_dst(&fl, np->opt, &final);
......
......@@ -151,8 +151,8 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet->inet_dport;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = inet->inet_dport;
fl.fl6_sport = inet->inet_sport;
if (!fl.flowi_oif && (addr_type&IPV6_ADDR_MULTICAST))
fl.flowi_oif = np->mcast_oif;
......@@ -261,7 +261,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
serr->ee.ee_info = info;
serr->ee.ee_data = 0;
serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb);
serr->port = fl->fl_ip_dport;
serr->port = fl->fl6_dport;
__skb_pull(skb, skb_tail_pointer(skb) - skb->data);
skb_reset_transport_header(skb);
......
......@@ -448,8 +448,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
if (saddr)
ipv6_addr_copy(&fl.fl6_src, saddr);
fl.flowi_oif = iif;
fl.fl_icmp_type = type;
fl.fl_icmp_code = code;
fl.fl6_icmp_type = type;
fl.fl6_icmp_code = code;
security_skb_classify_flow(skb, &fl);
sk = icmpv6_xmit_lock(net);
......@@ -544,7 +544,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
if (saddr)
ipv6_addr_copy(&fl.fl6_src, saddr);
fl.flowi_oif = skb->dev->ifindex;
fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
fl.fl6_icmp_type = ICMPV6_ECHO_REPLY;
security_skb_classify_flow(skb, &fl);
sk = icmpv6_xmit_lock(net);
......@@ -794,8 +794,8 @@ void icmpv6_flow_init(struct sock *sk, struct flowi *fl,
ipv6_addr_copy(&fl->fl6_src, saddr);
ipv6_addr_copy(&fl->fl6_dst, daddr);
fl->flowi_proto = IPPROTO_ICMPV6;
fl->fl_icmp_type = type;
fl->fl_icmp_code = 0;
fl->fl6_icmp_type = type;
fl->fl6_icmp_code = 0;
fl->flowi_oif = oif;
security_sk_classify_flow(sk, fl);
}
......
......@@ -70,8 +70,8 @@ struct dst_entry *inet6_csk_route_req(struct sock *sk,
ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_rsk(req)->loc_port;
fl.fl6_dport = inet_rsk(req)->rmt_port;
fl.fl6_sport = inet_rsk(req)->loc_port;
security_req_classify_flow(req, &fl);
dst = ip6_dst_lookup_flow(sk, &fl, final_p, false);
......@@ -220,8 +220,8 @@ int inet6_csk_xmit(struct sk_buff *skb)
IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_sport = inet->inet_sport;
fl.fl_ip_dport = inet->inet_dport;
fl.fl6_sport = inet->inet_sport;
fl.fl6_dport = inet->inet_dport;
security_sk_classify_flow(sk, &fl);
final_p = fl6_update_dst(&fl, np->opt, &final);
......
......@@ -215,7 +215,7 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb,
int err = 0;
if (unlikely(fl->flowi_proto == IPPROTO_MH &&
fl->fl_mh_type <= IP6_MH_TYPE_MAX))
fl->fl6_mh_type <= IP6_MH_TYPE_MAX))
goto out;
if (likely(opt->dsthao)) {
......@@ -241,10 +241,10 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb,
sel.prefixlen_s = 128;
sel.family = AF_INET6;
sel.proto = fl->flowi_proto;
sel.dport = xfrm_flowi_dport(fl);
sel.dport = xfrm_flowi_dport(fl, &fl->uli_u);
if (sel.dport)
sel.dport_mask = htons(~0);
sel.sport = xfrm_flowi_sport(fl);
sel.sport = xfrm_flowi_sport(fl, &fl->uli_u);
if (sel.sport)
sel.sport_mask = htons(~0);
sel.ifindex = fl->flowi_oif;
......
......@@ -93,8 +93,8 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
fl.flowi_proto = IPPROTO_TCP;
ipv6_addr_copy(&fl.fl6_src, &oip6h->daddr);
ipv6_addr_copy(&fl.fl6_dst, &oip6h->saddr);
fl.fl_ip_sport = otcph.dest;
fl.fl_ip_dport = otcph.source;
fl.fl6_sport = otcph.dest;
fl.fl6_dport = otcph.source;
security_skb_classify_flow(oldskb, &fl);
dst = ip6_route_output(net, NULL, &fl);
if (dst == NULL || dst->error) {
......
......@@ -694,8 +694,8 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
code = iov->iov_base;
if (type && code) {
if (get_user(fl->fl_icmp_type, type) ||
get_user(fl->fl_icmp_code, code))
if (get_user(fl->fl6_icmp_type, type) ||
get_user(fl->fl6_icmp_code, code))
return -EFAULT;
probed = 1;
}
......@@ -706,7 +706,7 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
/* check if type field is readable or not. */
if (iov->iov_len > 2 - len) {
u8 __user *p = iov->iov_base;
if (get_user(fl->fl_mh_type, &p[2 - len]))
if (get_user(fl->fl6_mh_type, &p[2 - len]))
return -EFAULT;
probed = 1;
} else
......
......@@ -240,8 +240,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_sk(sk)->inet_sport;
fl.fl6_dport = inet_rsk(req)->rmt_port;
fl.fl6_sport = inet_sk(sk)->inet_sport;
security_req_classify_flow(req, &fl);
dst = ip6_dst_lookup_flow(sk, &fl, final_p, false);
......
......@@ -248,8 +248,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
(saddr ? saddr : &np->saddr));
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = usin->sin6_port;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = usin->sin6_port;
fl.fl6_sport = inet->inet_sport;
final_p = fl6_update_dst(&fl, np->opt, &final);
......@@ -401,8 +401,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.flowi_oif = sk->sk_bound_dev_if;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet->inet_dport;
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_dport = inet->inet_dport;
fl.fl6_sport = inet->inet_sport;
security_skb_classify_flow(skb, &fl);
dst = ip6_dst_lookup_flow(sk, &fl, NULL, false);
......@@ -493,8 +493,8 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
fl.fl6_flowlabel = 0;
fl.flowi_oif = treq->iif;
fl.flowi_mark = sk->sk_mark;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_rsk(req)->loc_port;
fl.fl6_dport = inet_rsk(req)->rmt_port;
fl.fl6_sport = inet_rsk(req)->loc_port;
security_req_classify_flow(req, &fl);
opt = np->opt;
......@@ -1057,8 +1057,8 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
fl.flowi_proto = IPPROTO_TCP;
fl.flowi_oif = inet6_iif(skb);
fl.fl_ip_dport = t1->dest;
fl.fl_ip_sport = t1->source;
fl.fl6_dport = t1->dest;
fl.fl6_sport = t1->source;
security_skb_classify_flow(skb, &fl);
/* Pass a socket to ip6_dst_lookup either it is for RST
......
......@@ -899,8 +899,8 @@ static int udp_v6_push_pending_frames(struct sock *sk)
* Create a UDP header
*/
uh = udp_hdr(skb);
uh->source = fl->fl_ip_sport;
uh->dest = fl->fl_ip_dport;
uh->source = fl->fl6_sport;
uh->dest = fl->fl6_dport;
uh->len = htons(up->len);
uh->check = 0;
......@@ -1036,7 +1036,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (sin6->sin6_port == 0)
return -EINVAL;
fl.fl_ip_dport = sin6->sin6_port;
fl.fl6_dport = sin6->sin6_port;
daddr = &sin6->sin6_addr;
if (np->sndflow) {
......@@ -1065,7 +1065,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (sk->sk_state != TCP_ESTABLISHED)
return -EDESTADDRREQ;
fl.fl_ip_dport = inet->inet_dport;
fl.fl6_dport = inet->inet_dport;
daddr = &np->daddr;
fl.fl6_flowlabel = np->flow_label;
connected = 1;
......@@ -1112,7 +1112,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
fl.fl6_dst.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.fl_ip_sport = inet->inet_sport;
fl.fl6_sport = inet->inet_sport;
final_p = fl6_update_dst(&fl, opt, &final);
if (final_p)
......
......@@ -158,8 +158,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
__be16 *ports = (__be16 *)exthdr;
fl->fl_ip_sport = ports[!!reverse];
fl->fl_ip_dport = ports[!reverse];
fl->fl6_sport = ports[!!reverse];
fl->fl6_dport = ports[!reverse];
}
fl->flowi_proto = nexthdr;
return;
......@@ -168,8 +168,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
u8 *icmp = (u8 *)exthdr;
fl->fl_icmp_type = icmp[0];
fl->fl_icmp_code = icmp[1];
fl->fl6_icmp_type = icmp[0];
fl->fl6_icmp_code = icmp[1];
}
fl->flowi_proto = nexthdr;
return;
......@@ -180,7 +180,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
struct ip6_mh *mh;
mh = (struct ip6_mh *)exthdr;
fl->fl_mh_type = mh->ip6mh_type;
fl->fl6_mh_type = mh->ip6mh_type;
}
fl->flowi_proto = nexthdr;
return;
......@@ -191,7 +191,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
case IPPROTO_ESP:
case IPPROTO_COMP:
default:
fl->fl_ipsec_spi = 0;
fl->fl6_ipsec_spi = 0;
fl->flowi_proto = nexthdr;
return;
}
......
......@@ -26,9 +26,9 @@ __xfrm6_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
* to current session. */
ipv6_addr_copy((struct in6_addr *)&sel->daddr, &fl->fl6_dst);
ipv6_addr_copy((struct in6_addr *)&sel->saddr, &fl->fl6_src);
sel->dport = xfrm_flowi_dport(fl);
sel->dport = xfrm_flowi_dport(fl, &fl->uli_u);
sel->dport_mask = htons(0xffff);
sel->sport = xfrm_flowi_sport(fl);
sel->sport = xfrm_flowi_sport(fl, &fl->uli_u);
sel->sport_mask = htons(0xffff);
sel->family = AF_INET6;
sel->prefixlen_d = 128;
......
......@@ -476,16 +476,16 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
memset(&fl, 0x0, sizeof(struct flowi));
fl.fl4_dst = daddr->v4.sin_addr.s_addr;
fl.fl_ip_dport = daddr->v4.sin_port;
fl.fl4_dport = daddr->v4.sin_port;
fl.flowi_proto = IPPROTO_SCTP;
if (asoc) {
fl.fl4_tos = RT_CONN_FLAGS(asoc->base.sk);
fl.flowi_oif = asoc->base.sk->sk_bound_dev_if;
fl.fl_ip_sport = htons(asoc->base.bind_addr.port);
fl.fl4_sport = htons(asoc->base.bind_addr.port);
}
if (saddr) {
fl.fl4_src = saddr->v4.sin_addr.s_addr;
fl.fl_ip_sport = saddr->v4.sin_port;
fl.fl4_sport = saddr->v4.sin_port;
}
SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ",
......@@ -534,7 +534,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
if ((laddr->state == SCTP_ADDR_SRC) &&
(AF_INET == laddr->a.sa.sa_family)) {
fl.fl4_src = laddr->a.v4.sin_addr.s_addr;
fl.fl_ip_sport = laddr->a.v4.sin_port;
fl.fl4_sport = laddr->a.v4.sin_port;
rt = ip_route_output_key(&init_net, &fl);
if (!IS_ERR(rt)) {
dst = &rt->dst;
......
......@@ -61,8 +61,8 @@ __xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
{
return addr_match(&fl->fl4_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(&fl->fl4_src, &sel->saddr, sel->prefixlen_s) &&
!((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
!((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
!((xfrm_flowi_dport(fl, &fl->uli_u) ^ sel->dport) & sel->dport_mask) &&
!((xfrm_flowi_sport(fl, &fl->uli_u) ^ sel->sport) & sel->sport_mask) &&
(fl->flowi_proto == sel->proto || !sel->proto) &&
(fl->flowi_oif == sel->ifindex || !sel->ifindex);
}
......@@ -72,8 +72,8 @@ __xfrm6_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
{
return addr_match(&fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(&fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
!((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
!((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
!((xfrm_flowi_dport(fl, &fl->uli_u) ^ sel->dport) & sel->dport_mask) &&
!((xfrm_flowi_sport(fl, &fl->uli_u) ^ sel->sport) & sel->sport_mask) &&
(fl->flowi_proto == sel->proto || !sel->proto) &&
(fl->flowi_oif == sel->ifindex || !sel->ifindex);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册