Commit bef55aeb authored by David S. Miller's avatar David S. Miller

decnet: Convert to use flowidn where applicable.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1958b856
...@@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr) ...@@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
ethaddr[5] = (__u8)(a >> 8); ethaddr[5] = (__u8)(a >> 8);
} }
static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp)
{ {
fl->u.dn.uli.ports.sport = scp->addrloc; fld->fld_sport = scp->addrloc;
fl->u.dn.uli.ports.dport = scp->addrrem; fld->fld_dport = scp->addrrem;
} }
extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
......
...@@ -98,7 +98,7 @@ struct dn_fib_table { ...@@ -98,7 +98,7 @@ struct dn_fib_table {
int (*delete)(struct dn_fib_table *t, struct rtmsg *r, int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
struct dn_kern_rta *rta, struct nlmsghdr *n, struct dn_kern_rta *rta, struct nlmsghdr *n,
struct netlink_skb_parms *req); struct netlink_skb_parms *req);
int (*lookup)(struct dn_fib_table *t, const struct flowi *fl, int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld,
struct dn_fib_res *res); struct dn_fib_res *res);
int (*flush)(struct dn_fib_table *t); int (*flush)(struct dn_fib_table *t);
int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
...@@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, ...@@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
struct dn_kern_rta *rta, struct dn_kern_rta *rta,
const struct nlmsghdr *nlh, int *errp); const struct nlmsghdr *nlh, int *errp);
extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
const struct flowi *fl, const struct flowidn *fld,
struct dn_fib_res *res); struct dn_fib_res *res);
extern void dn_fib_release_info(struct dn_fib_info *fi); extern void dn_fib_release_info(struct dn_fib_info *fi);
extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type);
extern void dn_fib_flush(void); extern void dn_fib_flush(void);
extern void dn_fib_select_multipath(const struct flowi *fl, extern void dn_fib_select_multipath(const struct flowidn *fld,
struct dn_fib_res *res); struct dn_fib_res *res);
/* /*
...@@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void); ...@@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void);
extern void dn_fib_rules_init(void); extern void dn_fib_rules_init(void);
extern void dn_fib_rules_cleanup(void); extern void dn_fib_rules_cleanup(void);
extern unsigned dnet_addr_type(__le16 addr); extern unsigned dnet_addr_type(__le16 addr);
extern int dn_fib_lookup(struct flowi *fl, struct dn_fib_res *res); extern int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res);
extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*******************************************************************************/ *******************************************************************************/
extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); extern int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *, struct sock *sk, int flags);
extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
extern void dn_rt_cache_flush(int delay); extern void dn_rt_cache_flush(int delay);
...@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay); ...@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay);
struct dn_route { struct dn_route {
struct dst_entry dst; struct dst_entry dst;
struct flowi fl; struct flowidn fld;
__le16 rt_saddr; __le16 rt_saddr;
__le16 rt_daddr; __le16 rt_daddr;
...@@ -82,12 +82,12 @@ struct dn_route { ...@@ -82,12 +82,12 @@ struct dn_route {
static inline bool dn_is_input_route(struct dn_route *rt) static inline bool dn_is_input_route(struct dn_route *rt)
{ {
return rt->fl.flowi_iif != 0; return rt->fld.flowidn_iif != 0;
} }
static inline bool dn_is_output_route(struct dn_route *rt) static inline bool dn_is_output_route(struct dn_route *rt)
{ {
return rt->fl.flowi_iif == 0; return rt->fld.flowidn_iif == 0;
} }
extern void dn_route_init(void); extern void dn_route_init(void);
......
...@@ -95,9 +95,17 @@ struct flowi6 { ...@@ -95,9 +95,17 @@ struct flowi6 {
struct flowidn { struct flowidn {
struct flowi_common __fl_common; struct flowi_common __fl_common;
#define flowidn_oif __fl_common.flowic_oif
#define flowidn_iif __fl_common.flowic_iif
#define flowidn_mark __fl_common.flowic_mark
#define flowidn_scope __fl_common.flowic_scope
#define flowidn_proto __fl_common.flowic_proto
#define flowidn_flags __fl_common.flowic_flags
__le16 daddr; __le16 daddr;
__le16 saddr; __le16 saddr;
union flowi_uli uli; union flowi_uli uli;
#define fld_sport uli.ports.sport
#define fld_dport uli.ports.dport
}; };
struct flowi { struct flowi {
...@@ -115,10 +123,6 @@ struct flowi { ...@@ -115,10 +123,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 fld_scope flowi_scope
#define fld_dst u.dn.daddr
#define fld_src u.dn.saddr
} __attribute__((__aligned__(BITS_PER_LONG/8))); } __attribute__((__aligned__(BITS_PER_LONG/8)));
static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4) static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4)
......
...@@ -908,7 +908,7 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen, ...@@ -908,7 +908,7 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen,
struct socket *sock = sk->sk_socket; struct socket *sock = sk->sk_socket;
struct dn_scp *scp = DN_SK(sk); struct dn_scp *scp = DN_SK(sk);
int err = -EISCONN; int err = -EISCONN;
struct flowi fl; struct flowidn fld;
if (sock->state == SS_CONNECTED) if (sock->state == SS_CONNECTED)
goto out; goto out;
...@@ -947,13 +947,13 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen, ...@@ -947,13 +947,13 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen,
memcpy(&scp->peer, addr, sizeof(struct sockaddr_dn)); memcpy(&scp->peer, addr, sizeof(struct sockaddr_dn));
err = -EHOSTUNREACH; err = -EHOSTUNREACH;
memset(&fl, 0, sizeof(fl)); memset(&fld, 0, sizeof(fld));
fl.flowi_oif = sk->sk_bound_dev_if; fld.flowidn_oif = sk->sk_bound_dev_if;
fl.fld_dst = dn_saddr2dn(&scp->peer); fld.daddr = dn_saddr2dn(&scp->peer);
fl.fld_src = dn_saddr2dn(&scp->addr); fld.saddr = dn_saddr2dn(&scp->addr);
dn_sk_ports_copy(&fl, scp); dn_sk_ports_copy(&fld, scp);
fl.flowi_proto = DNPROTO_NSP; fld.flowidn_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, flags) < 0) if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, flags) < 0)
goto out; goto out;
sk->sk_route_caps = sk->sk_dst_cache->dev->features; sk->sk_route_caps = sk->sk_dst_cache->dev->features;
sock->state = SS_CONNECTING; sock->state = SS_CONNECTING;
......
...@@ -201,7 +201,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct ...@@ -201,7 +201,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
int err; int err;
if (nh->nh_gw) { if (nh->nh_gw) {
struct flowi fl; struct flowidn fld;
struct dn_fib_res res; struct dn_fib_res res;
if (nh->nh_flags&RTNH_F_ONLINK) { if (nh->nh_flags&RTNH_F_ONLINK) {
...@@ -221,15 +221,15 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct ...@@ -221,15 +221,15 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
return 0; return 0;
} }
memset(&fl, 0, sizeof(fl)); memset(&fld, 0, sizeof(fld));
fl.fld_dst = nh->nh_gw; fld.daddr = nh->nh_gw;
fl.flowi_oif = nh->nh_oif; fld.flowidn_oif = nh->nh_oif;
fl.fld_scope = r->rtm_scope + 1; fld.flowidn_scope = r->rtm_scope + 1;
if (fl.fld_scope < RT_SCOPE_LINK) if (fld.flowidn_scope < RT_SCOPE_LINK)
fl.fld_scope = RT_SCOPE_LINK; fld.flowidn_scope = RT_SCOPE_LINK;
if ((err = dn_fib_lookup(&fl, &res)) != 0) if ((err = dn_fib_lookup(&fld, &res)) != 0)
return err; return err;
err = -EINVAL; err = -EINVAL;
...@@ -404,7 +404,7 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta ...@@ -404,7 +404,7 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta
return NULL; return NULL;
} }
int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi *fl, struct dn_fib_res *res) int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowidn *fld, struct dn_fib_res *res)
{ {
int err = dn_fib_props[type].error; int err = dn_fib_props[type].error;
...@@ -424,7 +424,8 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi * ...@@ -424,7 +424,8 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi *
for_nexthops(fi) { for_nexthops(fi) {
if (nh->nh_flags & RTNH_F_DEAD) if (nh->nh_flags & RTNH_F_DEAD)
continue; continue;
if (!fl->flowi_oif || fl->flowi_oif == nh->nh_oif) if (!fld->flowidn_oif ||
fld->flowidn_oif == nh->nh_oif)
break; break;
} }
if (nhsel < fi->fib_nhs) { if (nhsel < fi->fib_nhs) {
...@@ -445,7 +446,7 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi * ...@@ -445,7 +446,7 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi *
return err; return err;
} }
void dn_fib_select_multipath(const struct flowi *fl, struct dn_fib_res *res) void dn_fib_select_multipath(const struct flowidn *fld, struct dn_fib_res *res)
{ {
struct dn_fib_info *fi = res->fi; struct dn_fib_info *fi = res->fi;
int w; int w;
......
...@@ -78,7 +78,7 @@ static void dn_nsp_send(struct sk_buff *skb) ...@@ -78,7 +78,7 @@ static void dn_nsp_send(struct sk_buff *skb)
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
struct dn_scp *scp = DN_SK(sk); struct dn_scp *scp = DN_SK(sk);
struct dst_entry *dst; struct dst_entry *dst;
struct flowi fl; struct flowidn fld;
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
scp->stamp = jiffies; scp->stamp = jiffies;
...@@ -91,13 +91,13 @@ static void dn_nsp_send(struct sk_buff *skb) ...@@ -91,13 +91,13 @@ static void dn_nsp_send(struct sk_buff *skb)
return; return;
} }
memset(&fl, 0, sizeof(fl)); memset(&fld, 0, sizeof(fld));
fl.flowi_oif = sk->sk_bound_dev_if; fld.flowidn_oif = sk->sk_bound_dev_if;
fl.fld_src = dn_saddr2dn(&scp->addr); fld.saddr = dn_saddr2dn(&scp->addr);
fl.fld_dst = dn_saddr2dn(&scp->peer); fld.daddr = dn_saddr2dn(&scp->peer);
dn_sk_ports_copy(&fl, scp); dn_sk_ports_copy(&fld, scp);
fl.flowi_proto = DNPROTO_NSP; fld.flowidn_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, 0) == 0) { if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, 0) == 0) {
dst = sk_dst_get(sk); dst = sk_dst_get(sk);
sk->sk_route_caps = dst->dev->features; sk->sk_route_caps = dst->dev->features;
goto try_again; goto try_again;
......
This diff is collapsed.
...@@ -49,14 +49,15 @@ struct dn_fib_rule ...@@ -49,14 +49,15 @@ struct dn_fib_rule
}; };
int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res) int dn_fib_lookup(struct flowidn *flp, struct dn_fib_res *res)
{ {
struct fib_lookup_arg arg = { struct fib_lookup_arg arg = {
.result = res, .result = res,
}; };
int err; int err;
err = fib_rules_lookup(dn_fib_rules_ops, flp, 0, &arg); err = fib_rules_lookup(dn_fib_rules_ops,
flowidn_to_flowi(flp), 0, &arg);
res->r = arg.rule; res->r = arg.rule;
return err; return err;
...@@ -65,6 +66,7 @@ int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res) ...@@ -65,6 +66,7 @@ int dn_fib_lookup(struct flowi *flp, struct dn_fib_res *res)
static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp, static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp,
int flags, struct fib_lookup_arg *arg) int flags, struct fib_lookup_arg *arg)
{ {
struct flowidn *fld = &flp->u.dn;
int err = -EAGAIN; int err = -EAGAIN;
struct dn_fib_table *tbl; struct dn_fib_table *tbl;
...@@ -90,7 +92,7 @@ static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp, ...@@ -90,7 +92,7 @@ static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp,
if (tbl == NULL) if (tbl == NULL)
goto errout; goto errout;
err = tbl->lookup(tbl, flp, (struct dn_fib_res *)arg->result); err = tbl->lookup(tbl, fld, (struct dn_fib_res *)arg->result);
if (err > 0) if (err > 0)
err = -EAGAIN; err = -EAGAIN;
errout: errout:
...@@ -104,8 +106,9 @@ static const struct nla_policy dn_fib_rule_policy[FRA_MAX+1] = { ...@@ -104,8 +106,9 @@ static const struct nla_policy dn_fib_rule_policy[FRA_MAX+1] = {
static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
{ {
struct dn_fib_rule *r = (struct dn_fib_rule *)rule; struct dn_fib_rule *r = (struct dn_fib_rule *)rule;
__le16 daddr = fl->fld_dst; struct flowidn *fld = &fl->u.dn;
__le16 saddr = fl->fld_src; __le16 daddr = fld->daddr;
__le16 saddr = fld->saddr;
if (((saddr ^ r->src) & r->srcmask) || if (((saddr ^ r->src) & r->srcmask) ||
((daddr ^ r->dst) & r->dstmask)) ((daddr ^ r->dst) & r->dstmask))
...@@ -175,7 +178,7 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh, ...@@ -175,7 +178,7 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
unsigned dnet_addr_type(__le16 addr) unsigned dnet_addr_type(__le16 addr)
{ {
struct flowi fl = { .fld_dst = addr }; struct flowidn fld = { .daddr = addr };
struct dn_fib_res res; struct dn_fib_res res;
unsigned ret = RTN_UNICAST; unsigned ret = RTN_UNICAST;
struct dn_fib_table *tb = dn_fib_get_table(RT_TABLE_LOCAL, 0); struct dn_fib_table *tb = dn_fib_get_table(RT_TABLE_LOCAL, 0);
...@@ -183,7 +186,7 @@ unsigned dnet_addr_type(__le16 addr) ...@@ -183,7 +186,7 @@ unsigned dnet_addr_type(__le16 addr)
res.r = NULL; res.r = NULL;
if (tb) { if (tb) {
if (!tb->lookup(tb, &fl, &res)) { if (!tb->lookup(tb, &fld, &res)) {
ret = res.type; ret = res.type;
dn_fib_res_put(&res); dn_fib_res_put(&res);
} }
......
...@@ -764,7 +764,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb) ...@@ -764,7 +764,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb)
return found; return found;
} }
static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res) static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowidn *flp, struct dn_fib_res *res)
{ {
int err; int err;
struct dn_zone *dz; struct dn_zone *dz;
...@@ -773,7 +773,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, ...@@ -773,7 +773,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
read_lock(&dn_fib_tables_lock); read_lock(&dn_fib_tables_lock);
for(dz = t->dh_zone_list; dz; dz = dz->dz_next) { for(dz = t->dh_zone_list; dz; dz = dz->dz_next) {
struct dn_fib_node *f; struct dn_fib_node *f;
dn_fib_key_t k = dz_key(flp->fld_dst, dz); dn_fib_key_t k = dz_key(flp->daddr, dz);
for(f = dz_chain(k, dz); f; f = f->fn_next) { for(f = dz_chain(k, dz); f; f = f->fn_next) {
if (!dn_key_eq(k, f->fn_key)) { if (!dn_key_eq(k, f->fn_key)) {
...@@ -788,7 +788,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, ...@@ -788,7 +788,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
if (f->fn_state&DN_S_ZOMBIE) if (f->fn_state&DN_S_ZOMBIE)
continue; continue;
if (f->fn_scope < flp->fld_scope) if (f->fn_scope < flp->flowidn_scope)
continue; continue;
err = dn_fib_semantic_match(f->fn_type, DN_FIB_INFO(f), flp, res); err = dn_fib_semantic_match(f->fn_type, DN_FIB_INFO(f), flp, res);
......
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