Skip to content

Commit

Permalink
decnet: Convert to use flowidn where applicable.
Browse files Browse the repository at this point in the history
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 12, 2011
1 parent 1958b85 commit bef55ae
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 185 deletions.
6 changes: 3 additions & 3 deletions include/net/dn.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
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;
fl->u.dn.uli.ports.dport = scp->addrrem;
fld->fld_sport = scp->addrloc;
fld->fld_dport = scp->addrrem;
}

extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
Expand Down
8 changes: 4 additions & 4 deletions include/net/dn_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct dn_fib_table {
int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
struct dn_kern_rta *rta, struct nlmsghdr *n,
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);
int (*flush)(struct dn_fib_table *t);
int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
Expand All @@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
struct dn_kern_rta *rta,
const struct nlmsghdr *nlh, int *errp);
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);
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 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);

/*
Expand All @@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void);
extern void dn_fib_rules_init(void);
extern void dn_fib_rules_cleanup(void);
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);

Expand Down
8 changes: 4 additions & 4 deletions include/net/dn_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*******************************************************************************/

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 void dn_rt_cache_flush(int delay);

Expand Down Expand Up @@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay);
struct dn_route {
struct dst_entry dst;

struct flowi fl;
struct flowidn fld;

__le16 rt_saddr;
__le16 rt_daddr;
Expand All @@ -82,12 +82,12 @@ struct dn_route {

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)
{
return rt->fl.flowi_iif == 0;
return rt->fld.flowidn_iif == 0;
}

extern void dn_route_init(void);
Expand Down
12 changes: 8 additions & 4 deletions include/net/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,17 @@ struct flowi6 {

struct flowidn {
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 saddr;
union flowi_uli uli;
#define fld_sport uli.ports.sport
#define fld_dport uli.ports.dport
};

struct flowi {
Expand All @@ -115,10 +123,6 @@ struct flowi {
#define flowi_proto u.__fl_common.flowic_proto
#define flowi_flags u.__fl_common.flowic_flags
#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)));

static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4)
Expand Down
16 changes: 8 additions & 8 deletions net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ static int __dn_connect(struct sock *sk, struct sockaddr_dn *addr, int addrlen,
struct socket *sock = sk->sk_socket;
struct dn_scp *scp = DN_SK(sk);
int err = -EISCONN;
struct flowi fl;
struct flowidn fld;

if (sock->state == SS_CONNECTED)
goto out;
Expand Down Expand Up @@ -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));

err = -EHOSTUNREACH;
memset(&fl, 0, sizeof(fl));
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.flowi_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, flags) < 0)
memset(&fld, 0, sizeof(fld));
fld.flowidn_oif = sk->sk_bound_dev_if;
fld.daddr = dn_saddr2dn(&scp->peer);
fld.saddr = dn_saddr2dn(&scp->addr);
dn_sk_ports_copy(&fld, scp);
fld.flowidn_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, flags) < 0)
goto out;
sk->sk_route_caps = sk->sk_dst_cache->dev->features;
sock->state = SS_CONNECTING;
Expand Down
23 changes: 12 additions & 11 deletions net/decnet/dn_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
int err;

if (nh->nh_gw) {
struct flowi fl;
struct flowidn fld;
struct dn_fib_res res;

if (nh->nh_flags&RTNH_F_ONLINK) {
Expand All @@ -221,15 +221,15 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
return 0;
}

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

if (fl.fld_scope < RT_SCOPE_LINK)
fl.fld_scope = RT_SCOPE_LINK;
if (fld.flowidn_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;

err = -EINVAL;
Expand Down Expand Up @@ -404,7 +404,7 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta
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;

Expand All @@ -424,7 +424,8 @@ 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->flowi_oif || fl->flowi_oif == nh->nh_oif)
if (!fld->flowidn_oif ||
fld->flowidn_oif == nh->nh_oif)
break;
}
if (nhsel < fi->fib_nhs) {
Expand All @@ -445,7 +446,7 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowi *
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;
int w;
Expand Down
16 changes: 8 additions & 8 deletions net/decnet/dn_nsp_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void dn_nsp_send(struct sk_buff *skb)
struct sock *sk = skb->sk;
struct dn_scp *scp = DN_SK(sk);
struct dst_entry *dst;
struct flowi fl;
struct flowidn fld;

skb_reset_transport_header(skb);
scp->stamp = jiffies;
Expand All @@ -91,13 +91,13 @@ static void dn_nsp_send(struct sk_buff *skb)
return;
}

memset(&fl, 0, sizeof(fl));
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.flowi_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fl, sk, 0) == 0) {
memset(&fld, 0, sizeof(fld));
fld.flowidn_oif = sk->sk_bound_dev_if;
fld.saddr = dn_saddr2dn(&scp->addr);
fld.daddr = dn_saddr2dn(&scp->peer);
dn_sk_ports_copy(&fld, scp);
fld.flowidn_proto = DNPROTO_NSP;
if (dn_route_output_sock(&sk->sk_dst_cache, &fld, sk, 0) == 0) {
dst = sk_dst_get(sk);
sk->sk_route_caps = dst->dev->features;
goto try_again;
Expand Down
Loading

0 comments on commit bef55ae

Please sign in to comment.