Skip to content

Commit

Permalink
net: use the macros defined for the members of flowi
Browse files Browse the repository at this point in the history
Use the macros defined for the members of flowi to clean the code up.

Signed-off-by: Changli Gao <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
xiaosuo authored and davem330 committed Nov 17, 2010
1 parent dd68ad2 commit 5811662
Show file tree
Hide file tree
Showing 32 changed files with 171 additions and 316 deletions.
12 changes: 5 additions & 7 deletions include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,12 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
{
struct flowi fl = { .oif = oif,
.mark = sk->sk_mark,
.nl_u = { .ip4_u = { .daddr = dst,
.saddr = src,
.tos = tos } },
.fl4_dst = dst,
.fl4_src = src,
.fl4_tos = tos,
.proto = protocol,
.uli_u = { .ports =
{ .sport = sport,
.dport = dport } } };

.fl_ip_sport = sport,
.fl_ip_dport = dport };
int err;
struct net *net = sock_net(sk);

Expand Down
3 changes: 2 additions & 1 deletion net/atm/clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
struct atmarp_entry *entry;
int error;
struct clip_vcc *clip_vcc;
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = ip, .tos = 1}} };
struct flowi fl = { .fl4_dst = ip,
.fl4_tos = 1 };
struct rtable *rt;

if (vcc->push != clip_push) {
Expand Down
9 changes: 2 additions & 7 deletions net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,8 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
if (dnat_took_place(skb)) {
if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = iph->daddr,
.saddr = 0,
.tos = RT_TOS(iph->tos) },
},
.proto = 0,
.fl4_dst = iph->daddr,
.fl4_tos = RT_TOS(iph->tos),
};
struct in_device *in_dev = __in_dev_get_rcu(dev);

Expand Down
13 changes: 5 additions & 8 deletions net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,12 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
{
struct rtable *rt;
struct flowi fl = { .oif = skb_rtable(skb)->rt_iif,
.nl_u = { .ip4_u =
{ .daddr = ip_hdr(skb)->saddr,
.saddr = ip_hdr(skb)->daddr,
.tos = RT_CONN_FLAGS(sk) } },
.fl4_dst = ip_hdr(skb)->saddr,
.fl4_src = ip_hdr(skb)->daddr,
.fl4_tos = RT_CONN_FLAGS(sk),
.proto = sk->sk_protocol,
.uli_u = { .ports =
{ .sport = dccp_hdr(skb)->dccph_dport,
.dport = dccp_hdr(skb)->dccph_sport }
}
.fl_ip_sport = dccp_hdr(skb)->dccph_dport,
.fl_ip_dport = dccp_hdr(skb)->dccph_sport
};

security_skb_classify_flow(skb, &fl);
Expand Down
22 changes: 9 additions & 13 deletions net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ static void dn_dst_link_failure(struct sk_buff *skb)

static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
{
return ((fl1->nl_u.dn_u.daddr ^ fl2->nl_u.dn_u.daddr) |
(fl1->nl_u.dn_u.saddr ^ fl2->nl_u.dn_u.saddr) |
return ((fl1->fld_dst ^ fl2->fld_dst) |
(fl1->fld_src ^ fl2->fld_src) |
(fl1->mark ^ fl2->mark) |
(fl1->nl_u.dn_u.scope ^ fl2->nl_u.dn_u.scope) |
(fl1->fld_scope ^ fl2->fld_scope) |
(fl1->oif ^ fl2->oif) |
(fl1->iif ^ fl2->iif)) == 0;
}
Expand Down Expand Up @@ -882,11 +882,9 @@ static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_re

static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *oldflp, int try_hard)
{
struct flowi fl = { .nl_u = { .dn_u =
{ .daddr = oldflp->fld_dst,
.saddr = oldflp->fld_src,
.scope = RT_SCOPE_UNIVERSE,
} },
struct flowi fl = { .fld_dst = oldflp->fld_dst,
.fld_src = oldflp->fld_src,
.fld_scope = RT_SCOPE_UNIVERSE,
.mark = oldflp->mark,
.iif = init_net.loopback_dev->ifindex,
.oif = oldflp->oif };
Expand Down Expand Up @@ -1230,11 +1228,9 @@ static int dn_route_input_slow(struct sk_buff *skb)
int flags = 0;
__le16 gateway = 0;
__le16 local_src = 0;
struct flowi fl = { .nl_u = { .dn_u =
{ .daddr = cb->dst,
.saddr = cb->src,
.scope = RT_SCOPE_UNIVERSE,
} },
struct flowi fl = { .fld_dst = cb->dst,
.fld_src = cb->src,
.fld_scope = RT_SCOPE_UNIVERSE,
.mark = skb->mark,
.iif = skb->dev->ifindex };
struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE };
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/dn_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,

unsigned dnet_addr_type(__le16 addr)
{
struct flowi fl = { .nl_u = { .dn_u = { .daddr = addr } } };
struct flowi fl = { .fld_dst = addr };
struct dn_fib_res res;
unsigned ret = RTN_UNICAST;
struct dn_fib_table *tb = dn_fib_get_table(RT_TABLE_LOCAL, 0);
Expand Down
18 changes: 5 additions & 13 deletions net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,21 +1148,13 @@ int inet_sk_rebuild_header(struct sock *sk)
struct flowi fl = {
.oif = sk->sk_bound_dev_if,
.mark = sk->sk_mark,
.nl_u = {
.ip4_u = {
.daddr = daddr,
.saddr = inet->inet_saddr,
.tos = RT_CONN_FLAGS(sk),
},
},
.fl4_dst = daddr,
.fl4_src = inet->inet_saddr,
.fl4_tos = RT_CONN_FLAGS(sk),
.proto = sk->sk_protocol,
.flags = inet_sk_flowi_flags(sk),
.uli_u = {
.ports = {
.sport = inet->inet_sport,
.dport = inet->inet_dport,
},
},
.fl_ip_sport = inet->inet_sport,
.fl_ip_dport = inet->inet_dport,
};

security_sk_classify_flow(sk, &fl);
Expand Down
12 changes: 6 additions & 6 deletions net/ipv4/arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ static int arp_ignore(struct in_device *in_dev, __be32 sip, __be32 tip)

static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev)
{
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = sip,
.saddr = tip } } };
struct flowi fl = { .fl4_dst = sip,
.fl4_src = tip };
struct rtable *rt;
int flag = 0;
/*unsigned long now; */
Expand Down Expand Up @@ -1061,8 +1061,8 @@ static int arp_req_set(struct net *net, struct arpreq *r,
if (r->arp_flags & ATF_PERM)
r->arp_flags |= ATF_COM;
if (dev == NULL) {
struct flowi fl = { .nl_u.ip4_u = { .daddr = ip,
.tos = RTO_ONLINK } };
struct flowi fl = { .fl4_dst = ip,
.fl4_tos = RTO_ONLINK };
struct rtable *rt;
err = ip_route_output_key(net, &rt, &fl);
if (err != 0)
Expand Down Expand Up @@ -1169,8 +1169,8 @@ static int arp_req_delete(struct net *net, struct arpreq *r,

ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
if (dev == NULL) {
struct flowi fl = { .nl_u.ip4_u = { .daddr = ip,
.tos = RTO_ONLINK } };
struct flowi fl = { .fl4_dst = ip,
.fl4_tos = RTO_ONLINK };
struct rtable *rt;
err = ip_route_output_key(net, &rt, &fl);
if (err != 0)
Expand Down
28 changes: 8 additions & 20 deletions net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ static void fib_flush(struct net *net)
struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref)
{
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = addr
}
},
.fl4_dst = addr,
.flags = FLOWI_FLAG_MATCH_ANY_IIF
};
struct fib_result res = { 0 };
Expand Down Expand Up @@ -193,7 +189,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net,
const struct net_device *dev,
__be32 addr)
{
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
struct flowi fl = { .fl4_dst = addr };
struct fib_result res;
unsigned ret = RTN_BROADCAST;
struct fib_table *local_table;
Expand Down Expand Up @@ -247,13 +243,9 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
{
struct in_device *in_dev;
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = src,
.saddr = dst,
.tos = tos
}
},
.fl4_dst = src,
.fl4_src = dst,
.fl4_tos = tos,
.mark = mark,
.iif = oif
};
Expand Down Expand Up @@ -853,13 +845,9 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
struct fib_result res;
struct flowi fl = {
.mark = frn->fl_mark,
.nl_u = {
.ip4_u = {
.daddr = frn->fl_addr,
.tos = frn->fl_tos,
.scope = frn->fl_scope
}
}
.fl4_dst = frn->fl_addr,
.fl4_tos = frn->fl_tos,
.fl4_scope = frn->fl_scope,
};

#ifdef CONFIG_IP_MULTIPLE_TABLES
Expand Down
8 changes: 2 additions & 6 deletions net/ipv4/fib_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,8 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
rcu_read_lock();
{
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = nh->nh_gw,
.scope = cfg->fc_scope + 1,
},
},
.fl4_dst = nh->nh_gw,
.fl4_scope = cfg->fc_scope + 1,
.oif = nh->nh_oif,
};

Expand Down
28 changes: 9 additions & 19 deletions net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,9 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
daddr = icmp_param->replyopts.faddr;
}
{
struct flowi fl = { .nl_u = { .ip4_u =
{ .daddr = daddr,
.saddr = rt->rt_spec_dst,
.tos = RT_TOS(ip_hdr(skb)->tos) } },
struct flowi fl = { .fl4_dst= daddr,
.fl4_src = rt->rt_spec_dst,
.fl4_tos = RT_TOS(ip_hdr(skb)->tos),
.proto = IPPROTO_ICMP };
security_skb_classify_flow(skb, &fl);
if (ip_route_output_key(net, &rt, &fl))
Expand Down Expand Up @@ -542,22 +541,13 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)

{
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = icmp_param.replyopts.srr ?
icmp_param.replyopts.faddr :
iph->saddr,
.saddr = saddr,
.tos = RT_TOS(tos)
}
},
.fl4_dst = icmp_param.replyopts.srr ?
icmp_param.replyopts.faddr : iph->saddr,
.fl4_src = saddr,
.fl4_tos = RT_TOS(tos),
.proto = IPPROTO_ICMP,
.uli_u = {
.icmpt = {
.type = type,
.code = code
}
}
.fl_icmp_type = type,
.fl_icmp_code = code,
};
int err;
struct rtable *rt2;
Expand Down
8 changes: 3 additions & 5 deletions net/ipv4/igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)

{
struct flowi fl = { .oif = dev->ifindex,
.nl_u = { .ip4_u = {
.daddr = IGMPV3_ALL_MCR } },
.fl4_dst = IGMPV3_ALL_MCR,
.proto = IPPROTO_IGMP };
if (ip_route_output_key(net, &rt, &fl)) {
kfree_skb(skb);
Expand Down Expand Up @@ -660,7 +659,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,

{
struct flowi fl = { .oif = dev->ifindex,
.nl_u = { .ip4_u = { .daddr = dst } },
.fl4_dst = dst,
.proto = IPPROTO_IGMP };
if (ip_route_output_key(net, &rt, &fl))
return -1;
Expand Down Expand Up @@ -1425,8 +1424,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev)
/* RTNL is locked */
static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr)
{
struct flowi fl = { .nl_u = { .ip4_u =
{ .daddr = imr->imr_multiaddr.s_addr } } };
struct flowi fl = { .fl4_dst = imr->imr_multiaddr.s_addr };
struct rtable *rt;
struct net_device *dev = NULL;
struct in_device *idev = NULL;
Expand Down
15 changes: 6 additions & 9 deletions net/ipv4/inet_connection_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,14 @@ struct dst_entry *inet_csk_route_req(struct sock *sk,
struct ip_options *opt = inet_rsk(req)->opt;
struct flowi fl = { .oif = sk->sk_bound_dev_if,
.mark = sk->sk_mark,
.nl_u = { .ip4_u =
{ .daddr = ((opt && opt->srr) ?
opt->faddr :
ireq->rmt_addr),
.saddr = ireq->loc_addr,
.tos = RT_CONN_FLAGS(sk) } },
.fl4_dst = ((opt && opt->srr) ?
opt->faddr : ireq->rmt_addr),
.fl4_src = ireq->loc_addr,
.fl4_tos = RT_CONN_FLAGS(sk),
.proto = sk->sk_protocol,
.flags = inet_sk_flowi_flags(sk),
.uli_u = { .ports =
{ .sport = inet_sk(sk)->inet_sport,
.dport = ireq->rmt_port } } };
.fl_ip_sport = inet_sk(sk)->inet_sport,
.fl_ip_dport = ireq->rmt_port };
struct net *net = sock_net(sk);

security_req_classify_flow(req, &fl);
Expand Down
31 changes: 9 additions & 22 deletions net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,9 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
{
struct flowi fl = {
.oif = tunnel->parms.link,
.nl_u = {
.ip4_u = {
.daddr = dst,
.saddr = tiph->saddr,
.tos = RT_TOS(tos)
}
},
.proto = IPPROTO_GRE,
.fl4_dst = dst,
.fl4_src = tiph->saddr,
.fl4_tos = RT_TOS(tos),
.fl_gre_key = tunnel->parms.o_key
};
if (ip_route_output_key(dev_net(dev), &rt, &fl)) {
Expand Down Expand Up @@ -951,13 +946,9 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev)
if (iph->daddr) {
struct flowi fl = {
.oif = tunnel->parms.link,
.nl_u = {
.ip4_u = {
.daddr = iph->daddr,
.saddr = iph->saddr,
.tos = RT_TOS(iph->tos)
}
},
.fl4_dst = iph->daddr,
.fl4_src = iph->saddr,
.fl4_tos = RT_TOS(iph->tos),
.proto = IPPROTO_GRE,
.fl_gre_key = tunnel->parms.o_key
};
Expand Down Expand Up @@ -1217,13 +1208,9 @@ static int ipgre_open(struct net_device *dev)
if (ipv4_is_multicast(t->parms.iph.daddr)) {
struct flowi fl = {
.oif = t->parms.link,
.nl_u = {
.ip4_u = {
.daddr = t->parms.iph.daddr,
.saddr = t->parms.iph.saddr,
.tos = RT_TOS(t->parms.iph.tos)
}
},
.fl4_dst = t->parms.iph.daddr,
.fl4_src = t->parms.iph.saddr,
.fl4_tos = RT_TOS(t->parms.iph.tos),
.proto = IPPROTO_GRE,
.fl_gre_key = t->parms.o_key
};
Expand Down
Loading

0 comments on commit 5811662

Please sign in to comment.