Commit 9cce96df authored by David S. Miller's avatar David S. Miller

net: Put fl4_* macros to struct flowi4 and use them again.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f42454d6
...@@ -61,6 +61,13 @@ struct flowi4 { ...@@ -61,6 +61,13 @@ struct flowi4 {
__be32 daddr; __be32 daddr;
__be32 saddr; __be32 saddr;
union flowi_uli uli; union flowi_uli uli;
#define fl4_sport uli.ports.sport
#define fl4_dport uli.ports.dport
#define fl4_icmp_type uli.icmpt.type
#define fl4_icmp_code uli.icmpt.code
#define fl4_ipsec_spi uli.spi
#define fl4_mh_type uli.mht.type
#define fl4_gre_key uli.gre_key
}; };
struct flowi6 { struct flowi6 {
...@@ -101,8 +108,6 @@ struct flowi { ...@@ -101,8 +108,6 @@ struct flowi {
#define flowi_proto u.__fl_common.flowic_proto #define flowi_proto u.__fl_common.flowic_proto
#define flowi_flags u.__fl_common.flowic_flags #define flowi_flags u.__fl_common.flowic_flags
#define flowi_secid u.__fl_common.flowic_secid #define flowi_secid u.__fl_common.flowic_secid
#define fl4_tos flowi_tos
#define fl4_scope flowi_scope
#define fld_scope flowi_scope #define fld_scope flowi_scope
#define fld_dst u.dn.daddr #define fld_dst u.dn.daddr
...@@ -110,15 +115,6 @@ struct flowi { ...@@ -110,15 +115,6 @@ struct flowi {
#define fl6_dst u.ip6.daddr #define fl6_dst u.ip6.daddr
#define fl6_src u.ip6.saddr #define fl6_src u.ip6.saddr
#define fl6_flowlabel u.ip6.flowlabel #define fl6_flowlabel u.ip6.flowlabel
#define fl4_dst u.ip4.daddr
#define fl4_src u.ip4.saddr
#define fl4_sport u.ip4.uli.ports.sport
#define fl4_dport u.ip4.uli.ports.dport
#define fl4_icmp_type u.ip4.uli.icmpt.type
#define fl4_icmp_code u.ip4.uli.icmpt.code
#define fl4_ipsec_spi u.ip4.uli.spi
#define fl4_mh_type u.ip4.uli.mht.type
#define fl4_gre_key u.ip4.uli.gre_key
#define fl6_sport u.ip6.uli.ports.sport #define fl6_sport u.ip6.uli.ports.sport
#define fl6_dport u.ip6.uli.ports.dport #define fl6_dport u.ip6.uli.ports.dport
#define fl6_icmp_type u.ip6.uli.icmpt.type #define fl6_icmp_type u.ip6.uli.icmpt.type
......
...@@ -157,8 +157,8 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock ...@@ -157,8 +157,8 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock
.saddr = saddr, .saddr = saddr,
.flowi4_tos = tos, .flowi4_tos = tos,
.flowi4_proto = proto, .flowi4_proto = proto,
.uli.ports.dport = dport, .fl4_dport = dport,
.uli.ports.sport = sport, .fl4_sport = sport,
}; };
if (sk) if (sk)
security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
...@@ -175,7 +175,7 @@ static inline struct rtable *ip_route_output_gre(struct net *net, ...@@ -175,7 +175,7 @@ static inline struct rtable *ip_route_output_gre(struct net *net,
.saddr = saddr, .saddr = saddr,
.flowi4_tos = tos, .flowi4_tos = tos,
.flowi4_proto = IPPROTO_GRE, .flowi4_proto = IPPROTO_GRE,
.uli.gre_key = gre_key, .fl4_gre_key = gre_key,
}; };
return ip_route_output_key(net, &fl4); return ip_route_output_key(net, &fl4);
} }
...@@ -235,8 +235,8 @@ static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos, ...@@ -235,8 +235,8 @@ static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos,
.saddr = src, .saddr = src,
.flowi4_tos = tos, .flowi4_tos = tos,
.flowi4_proto = protocol, .flowi4_proto = protocol,
.uli.ports.sport = sport, .fl4_sport = sport,
.uli.ports.dport = dport, .fl4_dport = dport,
}; };
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct rtable *rt; struct rtable *rt;
...@@ -273,8 +273,8 @@ static inline struct rtable *ip_route_newports(struct rtable *rt, ...@@ -273,8 +273,8 @@ static inline struct rtable *ip_route_newports(struct rtable *rt,
.saddr = rt->rt_key_src, .saddr = rt->rt_key_src,
.flowi4_tos = rt->rt_tos, .flowi4_tos = rt->rt_tos,
.flowi4_proto = protocol, .flowi4_proto = protocol,
.uli.ports.sport = sport, .fl4_sport = sport,
.uli.ports.dport = dport .fl4_dport = dport
}; };
if (inet_sk(sk)->transparent) if (inet_sk(sk)->transparent)
fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC; fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
......
...@@ -471,8 +471,8 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk, ...@@ -471,8 +471,8 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
.saddr = ip_hdr(skb)->daddr, .saddr = ip_hdr(skb)->daddr,
.flowi4_tos = RT_CONN_FLAGS(sk), .flowi4_tos = RT_CONN_FLAGS(sk),
.flowi4_proto = sk->sk_protocol, .flowi4_proto = sk->sk_protocol,
.uli.ports.sport = dccp_hdr(skb)->dccph_dport, .fl4_sport = dccp_hdr(skb)->dccph_dport,
.uli.ports.dport = dccp_hdr(skb)->dccph_sport, .fl4_dport = dccp_hdr(skb)->dccph_sport,
}; };
security_skb_classify_flow(skb, flowi4_to_flowi(&fl4)); security_skb_classify_flow(skb, flowi4_to_flowi(&fl4));
......
...@@ -384,8 +384,8 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in, ...@@ -384,8 +384,8 @@ static struct rtable *icmp_route_lookup(struct net *net, struct sk_buff *skb_in,
.saddr = saddr, .saddr = saddr,
.flowi4_tos = RT_TOS(tos), .flowi4_tos = RT_TOS(tos),
.flowi4_proto = IPPROTO_ICMP, .flowi4_proto = IPPROTO_ICMP,
.uli.icmpt.type = type, .fl4_icmp_type = type,
.uli.icmpt.code = code, .fl4_icmp_code = code,
}; };
struct rtable *rt, *rt2; struct rtable *rt, *rt2;
int err; int err;
......
...@@ -365,8 +365,8 @@ struct dst_entry *inet_csk_route_req(struct sock *sk, ...@@ -365,8 +365,8 @@ struct dst_entry *inet_csk_route_req(struct sock *sk,
.flowi4_tos = RT_CONN_FLAGS(sk), .flowi4_tos = RT_CONN_FLAGS(sk),
.flowi4_proto = sk->sk_protocol, .flowi4_proto = sk->sk_protocol,
.flowi4_flags = inet_sk_flowi_flags(sk), .flowi4_flags = inet_sk_flowi_flags(sk),
.uli.ports.sport = inet_sk(sk)->inet_sport, .fl4_sport = inet_sk(sk)->inet_sport,
.uli.ports.dport = ireq->rmt_port, .fl4_dport = ireq->rmt_port,
}; };
struct net *net = sock_net(sk); 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 ...@@ -1479,8 +1479,8 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
.daddr = daddr, .daddr = daddr,
.saddr = rt->rt_spec_dst, .saddr = rt->rt_spec_dst,
.flowi4_tos = RT_TOS(ip_hdr(skb)->tos), .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
.uli.ports.sport = tcp_hdr(skb)->dest, .fl4_sport = tcp_hdr(skb)->dest,
.uli.ports.dport = tcp_hdr(skb)->source, .fl4_dport = tcp_hdr(skb)->source,
.flowi4_proto = sk->sk_protocol, .flowi4_proto = sk->sk_protocol,
.flowi4_flags = ip_reply_arg_flowi_flags(arg), .flowi4_flags = ip_reply_arg_flowi_flags(arg),
}; };
......
...@@ -56,7 +56,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl) ...@@ -56,7 +56,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
t->dst.protonum == IPPROTO_UDPLITE || t->dst.protonum == IPPROTO_UDPLITE ||
t->dst.protonum == IPPROTO_DCCP || t->dst.protonum == IPPROTO_DCCP ||
t->dst.protonum == IPPROTO_SCTP) t->dst.protonum == IPPROTO_SCTP)
fl4->uli.ports.dport = t->dst.u.tcp.port; fl4->fl4_dport = t->dst.u.tcp.port;
} }
statusbit ^= IPS_NAT_MASK; statusbit ^= IPS_NAT_MASK;
...@@ -68,7 +68,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl) ...@@ -68,7 +68,7 @@ static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
t->dst.protonum == IPPROTO_UDPLITE || t->dst.protonum == IPPROTO_UDPLITE ||
t->dst.protonum == IPPROTO_DCCP || t->dst.protonum == IPPROTO_DCCP ||
t->dst.protonum == IPPROTO_SCTP) t->dst.protonum == IPPROTO_SCTP)
fl4->uli.ports.sport = t->src.u.tcp.port; fl4->fl4_sport = t->src.u.tcp.port;
} }
} }
#endif #endif
......
...@@ -433,8 +433,8 @@ static int raw_probe_proto_opt(struct flowi4 *fl4, struct msghdr *msg) ...@@ -433,8 +433,8 @@ static int raw_probe_proto_opt(struct flowi4 *fl4, struct msghdr *msg)
code = iov->iov_base; code = iov->iov_base;
if (type && code) { if (type && code) {
if (get_user(fl4->uli.icmpt.type, type) || if (get_user(fl4->fl4_icmp_type, type) ||
get_user(fl4->uli.icmpt.code, code)) get_user(fl4->fl4_icmp_code, code))
return -EFAULT; return -EFAULT;
probed = 1; probed = 1;
} }
......
...@@ -353,8 +353,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, ...@@ -353,8 +353,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
.flowi4_tos = RT_CONN_FLAGS(sk), .flowi4_tos = RT_CONN_FLAGS(sk),
.flowi4_proto = IPPROTO_TCP, .flowi4_proto = IPPROTO_TCP,
.flowi4_flags = inet_sk_flowi_flags(sk), .flowi4_flags = inet_sk_flowi_flags(sk),
.uli.ports.sport = th->dest, .fl4_sport = th->dest,
.uli.ports.dport = th->source, .fl4_dport = th->source,
}; };
security_req_classify_flow(req, flowi4_to_flowi(&fl4)); security_req_classify_flow(req, flowi4_to_flowi(&fl4));
rt = ip_route_output_key(sock_net(sk), &fl4); rt = ip_route_output_key(sock_net(sk), &fl4);
......
...@@ -778,7 +778,7 @@ static int udp_push_pending_frames(struct sock *sk) ...@@ -778,7 +778,7 @@ static int udp_push_pending_frames(struct sock *sk)
if (!skb) if (!skb)
goto out; goto out;
err = udp_send_skb(skb, fl4->daddr, fl4->uli.ports.dport); err = udp_send_skb(skb, fl4->daddr, fl4->fl4_dport);
out: out:
up->len = 0; up->len = 0;
...@@ -918,8 +918,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -918,8 +918,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.flowi4_proto = sk->sk_protocol, .flowi4_proto = sk->sk_protocol,
.flowi4_flags = (inet_sk_flowi_flags(sk) | .flowi4_flags = (inet_sk_flowi_flags(sk) |
FLOWI_FLAG_CAN_SLEEP), FLOWI_FLAG_CAN_SLEEP),
.uli.ports.sport = inet->inet_sport, .fl4_sport = inet->inet_sport,
.uli.ports.dport = dport, .fl4_dport = dport,
}; };
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
...@@ -976,8 +976,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -976,8 +976,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
fl4 = &inet->cork.fl.u.ip4; fl4 = &inet->cork.fl.u.ip4;
fl4->daddr = daddr; fl4->daddr = daddr;
fl4->saddr = saddr; fl4->saddr = saddr;
fl4->uli.ports.dport = dport; fl4->fl4_dport = dport;
fl4->uli.ports.sport = inet->inet_sport; fl4->fl4_sport = inet->inet_sport;
up->pending = AF_INET; up->pending = AF_INET;
do_append_data: do_append_data:
......
...@@ -119,8 +119,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -119,8 +119,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
pskb_may_pull(skb, xprth + 4 - skb->data)) { pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be16 *ports = (__be16 *)xprth; __be16 *ports = (__be16 *)xprth;
fl4->uli.ports.sport = ports[!!reverse]; fl4->fl4_sport = ports[!!reverse];
fl4->uli.ports.dport = ports[!reverse]; fl4->fl4_dport = ports[!reverse];
} }
break; break;
...@@ -128,8 +128,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -128,8 +128,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 2 - skb->data)) { if (pskb_may_pull(skb, xprth + 2 - skb->data)) {
u8 *icmp = xprth; u8 *icmp = xprth;
fl4->uli.icmpt.type = icmp[0]; fl4->fl4_icmp_type = icmp[0];
fl4->uli.icmpt.code = icmp[1]; fl4->fl4_icmp_code = icmp[1];
} }
break; break;
...@@ -137,7 +137,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -137,7 +137,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 4 - skb->data)) { if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be32 *ehdr = (__be32 *)xprth; __be32 *ehdr = (__be32 *)xprth;
fl4->uli.spi = ehdr[0]; fl4->fl4_ipsec_spi = ehdr[0];
} }
break; break;
...@@ -145,7 +145,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -145,7 +145,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 8 - skb->data)) { if (pskb_may_pull(skb, xprth + 8 - skb->data)) {
__be32 *ah_hdr = (__be32*)xprth; __be32 *ah_hdr = (__be32*)xprth;
fl4->uli.spi = ah_hdr[1]; fl4->fl4_ipsec_spi = ah_hdr[1];
} }
break; break;
...@@ -153,7 +153,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -153,7 +153,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (pskb_may_pull(skb, xprth + 4 - skb->data)) { if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
__be16 *ipcomp_hdr = (__be16 *)xprth; __be16 *ipcomp_hdr = (__be16 *)xprth;
fl4->uli.spi = htonl(ntohs(ipcomp_hdr[1])); fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
} }
break; break;
...@@ -165,13 +165,13 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse) ...@@ -165,13 +165,13 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
if (greflags[0] & GRE_KEY) { if (greflags[0] & GRE_KEY) {
if (greflags[0] & GRE_CSUM) if (greflags[0] & GRE_CSUM)
gre_hdr++; gre_hdr++;
fl4->uli.gre_key = gre_hdr[1]; fl4->fl4_gre_key = gre_hdr[1];
} }
} }
break; break;
default: default:
fl4->uli.spi = 0; fl4->fl4_ipsec_spi = 0;
break; break;
} }
} }
......
...@@ -476,16 +476,16 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, ...@@ -476,16 +476,16 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
memset(&fl4, 0x0, sizeof(struct flowi4)); memset(&fl4, 0x0, sizeof(struct flowi4));
fl4.daddr = daddr->v4.sin_addr.s_addr; fl4.daddr = daddr->v4.sin_addr.s_addr;
fl4.uli.ports.dport = daddr->v4.sin_port; fl4.fl4_dport = daddr->v4.sin_port;
fl4.flowi4_proto = IPPROTO_SCTP; fl4.flowi4_proto = IPPROTO_SCTP;
if (asoc) { if (asoc) {
fl4.flowi4_tos = RT_CONN_FLAGS(asoc->base.sk); fl4.flowi4_tos = RT_CONN_FLAGS(asoc->base.sk);
fl4.flowi4_oif = asoc->base.sk->sk_bound_dev_if; fl4.flowi4_oif = asoc->base.sk->sk_bound_dev_if;
fl4.uli.ports.sport = htons(asoc->base.bind_addr.port); fl4.fl4_sport = htons(asoc->base.bind_addr.port);
} }
if (saddr) { if (saddr) {
fl4.saddr = saddr->v4.sin_addr.s_addr; fl4.saddr = saddr->v4.sin_addr.s_addr;
fl4.uli.ports.sport = saddr->v4.sin_port; fl4.fl4_sport = saddr->v4.sin_port;
} }
SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ",
...@@ -534,7 +534,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, ...@@ -534,7 +534,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
if ((laddr->state == SCTP_ADDR_SRC) && if ((laddr->state == SCTP_ADDR_SRC) &&
(AF_INET == laddr->a.sa.sa_family)) { (AF_INET == laddr->a.sa.sa_family)) {
fl4.saddr = laddr->a.v4.sin_addr.s_addr; fl4.saddr = laddr->a.v4.sin_addr.s_addr;
fl4.uli.ports.sport = laddr->a.v4.sin_port; fl4.fl4_sport = laddr->a.v4.sin_port;
rt = ip_route_output_key(&init_net, &fl4); rt = ip_route_output_key(&init_net, &fl4);
if (!IS_ERR(rt)) { if (!IS_ERR(rt)) {
dst = &rt->dst; dst = &rt->dst;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment