Skip to content

Commit

Permalink
net: Put flowi_* prefix on AF independent members of struct flowi
Browse files Browse the repository at this point in the history
I intend to turn struct flowi into a union of AF specific flowi
structs.  There will be a common structure that each variant includes
first, much like struct sock_common.

This is the first step to move in that direction.

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Mar 12, 2011
1 parent ca11692 commit 1d28f42
Show file tree
Hide file tree
Showing 56 changed files with 365 additions and 351 deletions.
2 changes: 1 addition & 1 deletion drivers/infiniband/core/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
memset(&fl, 0, sizeof fl);
ipv6_addr_copy(&fl.fl6_dst, &dst_in->sin6_addr);
ipv6_addr_copy(&fl.fl6_src, &src_in->sin6_addr);
fl.oif = addr->bound_dev_if;
fl.flowi_oif = addr->bound_dev_if;

dst = ip6_route_output(&init_net, NULL, &fl);
if ((ret = dst->error))
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/cnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3429,7 +3429,7 @@ static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr,
memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &dst_addr->sin6_addr);
if (ipv6_addr_type(&fl.fl6_dst) & IPV6_ADDR_LINKLOCAL)
fl.oif = dst_addr->sin6_scope_id;
fl.flowi_oif = dst_addr->sin6_scope_id;

*dst = ip6_route_output(&init_net, NULL, &fl);
if (*dst)
Expand Down
4 changes: 2 additions & 2 deletions include/net/dn_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ struct dn_route {

static inline bool dn_is_input_route(struct dn_route *rt)
{
return rt->fl.iif != 0;
return rt->fl.flowi_iif != 0;
}

static inline bool dn_is_output_route(struct dn_route *rt)
{
return rt->fl.iif == 0;
return rt->fl.flowi_iif == 0;
}

extern void dn_route_init(void);
Expand Down
22 changes: 11 additions & 11 deletions include/net/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#include <asm/atomic.h>

struct flowi {
int oif;
int iif;
__u32 mark;
__u8 tos;
__u8 scope;
__u8 proto;
__u8 flags;
int flowi_oif;
int flowi_iif;
__u32 flowi_mark;
__u8 flowi_tos;
__u8 flowi_scope;
__u8 flowi_proto;
__u8 flowi_flags;
#define FLOWI_FLAG_ANYSRC 0x01
#define FLOWI_FLAG_PRECOW_METRICS 0x02
#define FLOWI_FLAG_CAN_SLEEP 0x04
__u32 secid;
__u32 flowi_secid;

union {
struct {
Expand Down Expand Up @@ -49,8 +49,8 @@ struct flowi {
#define fl6_flowlabel nl_u.ip6_u.flowlabel
#define fl4_dst nl_u.ip4_u.daddr
#define fl4_src nl_u.ip4_u.saddr
#define fl4_tos tos
#define fl4_scope scope
#define fl4_tos flowi_tos
#define fl4_scope flowi_scope

union {
struct {
Expand Down Expand Up @@ -116,7 +116,7 @@ extern atomic_t flow_cache_genid;
static inline int flow_cache_uli_match(const struct flowi *fl1,
const struct flowi *fl2)
{
return (fl1->proto == fl2->proto &&
return (fl1->flowi_proto == fl2->flowi_proto &&
!memcmp(&fl1->uli_u, &fl2->uli_u, sizeof(fl1->uli_u)));
}

Expand Down
36 changes: 18 additions & 18 deletions include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
__be32 saddr, u8 tos, int oif)
{
struct flowi fl = {
.oif = oif,
.flowi_oif = oif,
.fl4_dst = daddr,
.fl4_src = saddr,
.fl4_tos = tos,
Expand All @@ -150,13 +150,13 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct sock
__u8 proto, __u8 tos, int oif)
{
struct flowi fl = {
.oif = oif,
.flags = sk ? inet_sk_flowi_flags(sk) : 0,
.mark = sk ? sk->sk_mark : 0,
.flowi_oif = oif,
.flowi_flags = sk ? inet_sk_flowi_flags(sk) : 0,
.flowi_mark = sk ? sk->sk_mark : 0,
.fl4_dst = daddr,
.fl4_src = saddr,
.fl4_tos = tos,
.proto = proto,
.flowi_proto = proto,
.fl_ip_dport = dport,
.fl_ip_sport = sport,
};
Expand All @@ -170,11 +170,11 @@ static inline struct rtable *ip_route_output_gre(struct net *net,
__be32 gre_key, __u8 tos, int oif)
{
struct flowi fl = {
.oif = oif,
.flowi_oif = oif,
.fl4_dst = daddr,
.fl4_src = saddr,
.fl4_tos = tos,
.proto = IPPROTO_GRE,
.flowi_proto = IPPROTO_GRE,
.fl_gre_key = gre_key,
};
return ip_route_output_key(net, &fl);
Expand Down Expand Up @@ -228,23 +228,23 @@ 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 = { .oif = oif,
.mark = sk->sk_mark,
struct flowi fl = { .flowi_oif = oif,
.flowi_mark = sk->sk_mark,
.fl4_dst = dst,
.fl4_src = src,
.fl4_tos = tos,
.proto = protocol,
.flowi_proto = protocol,
.fl_ip_sport = sport,
.fl_ip_dport = dport };
struct net *net = sock_net(sk);
struct rtable *rt;

if (inet_sk(sk)->transparent)
fl.flags |= FLOWI_FLAG_ANYSRC;
fl.flowi_flags |= FLOWI_FLAG_ANYSRC;
if (protocol == IPPROTO_TCP)
fl.flags |= FLOWI_FLAG_PRECOW_METRICS;
fl.flowi_flags |= FLOWI_FLAG_PRECOW_METRICS;
if (can_sleep)
fl.flags |= FLOWI_FLAG_CAN_SLEEP;
fl.flowi_flags |= FLOWI_FLAG_CAN_SLEEP;

if (!dst || !src) {
rt = __ip_route_output_key(net, &fl);
Expand All @@ -264,19 +264,19 @@ 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 = { .oif = rt->rt_oif,
.mark = rt->rt_mark,
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,
.proto = protocol,
.flowi_proto = protocol,
.fl_ip_sport = sport,
.fl_ip_dport = dport };

if (inet_sk(sk)->transparent)
fl.flags |= FLOWI_FLAG_ANYSRC;
fl.flowi_flags |= FLOWI_FLAG_ANYSRC;
if (protocol == IPPROTO_TCP)
fl.flags |= FLOWI_FLAG_PRECOW_METRICS;
fl.flowi_flags |= FLOWI_FLAG_PRECOW_METRICS;
ip_rt_put(rt);
security_sk_classify_flow(sk, &fl);
return ip_route_output_flow(sock_net(sk), &fl, sk);
Expand Down
4 changes: 2 additions & 2 deletions include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ static __inline__
__be16 xfrm_flowi_sport(const struct flowi *fl)
{
__be16 port;
switch(fl->proto) {
switch(fl->flowi_proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
Expand All @@ -830,7 +830,7 @@ static __inline__
__be16 xfrm_flowi_dport(const struct flowi *fl)
{
__be16 port;
switch(fl->proto) {
switch(fl->flowi_proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
Expand Down
6 changes: 3 additions & 3 deletions net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
{
int ret = 0;

if (rule->iifindex && (rule->iifindex != fl->iif))
if (rule->iifindex && (rule->iifindex != fl->flowi_iif))
goto out;

if (rule->oifindex && (rule->oifindex != fl->oif))
if (rule->oifindex && (rule->oifindex != fl->flowi_oif))
goto out;

if ((rule->mark ^ fl->mark) & rule->mark_mask)
if ((rule->mark ^ fl->flowi_mark) & rule->mark_mask)
goto out;

ret = ops->match(rule, fl, flags);
Expand Down
17 changes: 9 additions & 8 deletions net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,15 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
struct sk_buff *skb)
{
struct rtable *rt;
struct flowi fl = { .oif = skb_rtable(skb)->rt_iif,
.fl4_dst = ip_hdr(skb)->saddr,
.fl4_src = ip_hdr(skb)->daddr,
.fl4_tos = RT_CONN_FLAGS(sk),
.proto = sk->sk_protocol,
.fl_ip_sport = dccp_hdr(skb)->dccph_dport,
.fl_ip_dport = dccp_hdr(skb)->dccph_sport
};
struct flowi fl = {
.flowi_oif = skb_rtable(skb)->rt_iif,
.fl4_dst = ip_hdr(skb)->saddr,
.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,
};

security_skb_classify_flow(skb, &fl);
rt = ip_route_output_flow(net, &fl, sk);
Expand Down
20 changes: 10 additions & 10 deletions net/dccp/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
for now.
*/
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_DCCP;
fl.flowi_proto = IPPROTO_DCCP;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.oif = sk->sk_bound_dev_if;
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fl_ip_dport = inet->inet_dport;
fl.fl_ip_sport = inet->inet_sport;
security_sk_classify_flow(sk, &fl);
Expand Down Expand Up @@ -248,11 +248,11 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
struct dst_entry *dst;

memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_DCCP;
fl.flowi_proto = IPPROTO_DCCP;
ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
fl.fl6_flowlabel = 0;
fl.oif = ireq6->iif;
fl.flowi_oif = ireq6->iif;
fl.fl_ip_dport = inet_rsk(req)->rmt_port;
fl.fl_ip_sport = inet_rsk(req)->loc_port;
security_req_classify_flow(req, &fl);
Expand Down Expand Up @@ -321,8 +321,8 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
ipv6_addr_copy(&fl.fl6_dst, &rxip6h->saddr);
ipv6_addr_copy(&fl.fl6_src, &rxip6h->daddr);

fl.proto = IPPROTO_DCCP;
fl.oif = inet6_iif(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;
security_skb_classify_flow(rxskb, &fl);
Expand Down Expand Up @@ -530,11 +530,11 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
struct flowi fl;

memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_DCCP;
fl.flowi_proto = IPPROTO_DCCP;
ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
final_p = fl6_update_dst(&fl, opt, &final);
ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
fl.oif = sk->sk_bound_dev_if;
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;
security_sk_classify_flow(sk, &fl);
Expand Down Expand Up @@ -953,10 +953,10 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
if (!ipv6_addr_any(&np->rcv_saddr))
saddr = &np->rcv_saddr;

fl.proto = IPPROTO_DCCP;
fl.flowi_proto = IPPROTO_DCCP;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
fl.oif = sk->sk_bound_dev_if;
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fl_ip_dport = usin->sin6_port;
fl.fl_ip_sport = inet->inet_sport;
security_sk_classify_flow(sk, &fl);
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,11 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen,

err = -EHOSTUNREACH;
memset(&fl, 0, sizeof(fl));
fl.oif = sk->sk_bound_dev_if;
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fld_dst = dn_saddr2dn(&scp->peer);
fl.fld_src = dn_saddr2dn(&scp->addr);
dn_sk_ports_copy(&fl, scp);
fl.proto = DNPROTO_NSP;
fl.flowi_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, flags) < 0)
goto out;
sk->sk_route_caps = sk->sk_dst_cache->dev->features;
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct

memset(&fl, 0, sizeof(fl));
fl.fld_dst = nh->nh_gw;
fl.oif = nh->nh_oif;
fl.flowi_oif = nh->nh_oif;
fl.fld_scope = r->rtm_scope + 1;

if (fl.fld_scope < RT_SCOPE_LINK)
Expand Down Expand Up @@ -424,7 +424,7 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi *
for_nexthops(fi) {
if (nh->nh_flags & RTNH_F_DEAD)
continue;
if (!fl->oif || fl->oif == nh->nh_oif)
if (!fl->flowi_oif || fl->flowi_oif == nh->nh_oif)
break;
}
if (nhsel < fi->fib_nhs) {
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_nsp_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ static void dn_nsp_send(struct sk_buff *skb)
}

memset(&fl, 0, sizeof(fl));
fl.oif = sk->sk_bound_dev_if;
fl.flowi_oif = sk->sk_bound_dev_if;
fl.fld_src = dn_saddr2dn(&scp->addr);
fl.fld_dst = dn_saddr2dn(&scp->peer);
dn_sk_ports_copy(&fl, scp);
fl.proto = DNPROTO_NSP;
fl.flowi_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, 0) == 0) {
dst = sk_dst_get(sk);
sk->sk_route_caps = dst->dev->features;
Expand Down
Loading

0 comments on commit 1d28f42

Please sign in to comment.