|
@@ -282,14 +282,14 @@ static void dn_dst_link_failure(struct sk_buff *skb)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
-static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
|
|
|
|
|
|
+static inline int compare_keys(struct flowidn *fl1, struct flowidn *fl2)
|
|
{
|
|
{
|
|
- return ((fl1->fld_dst ^ fl2->fld_dst) |
|
|
|
|
- (fl1->fld_src ^ fl2->fld_src) |
|
|
|
|
- (fl1->flowi_mark ^ fl2->flowi_mark) |
|
|
|
|
- (fl1->fld_scope ^ fl2->fld_scope) |
|
|
|
|
- (fl1->flowi_oif ^ fl2->flowi_oif) |
|
|
|
|
- (fl1->flowi_iif ^ fl2->flowi_iif)) == 0;
|
|
|
|
|
|
+ return ((fl1->daddr ^ fl2->daddr) |
|
|
|
|
+ (fl1->saddr ^ fl2->saddr) |
|
|
|
|
+ (fl1->flowidn_mark ^ fl2->flowidn_mark) |
|
|
|
|
+ (fl1->flowidn_scope ^ fl2->flowidn_scope) |
|
|
|
|
+ (fl1->flowidn_oif ^ fl2->flowidn_oif) |
|
|
|
|
+ (fl1->flowidn_iif ^ fl2->flowidn_iif)) == 0;
|
|
}
|
|
}
|
|
|
|
|
|
static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp)
|
|
static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp)
|
|
@@ -303,7 +303,7 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
|
|
spin_lock_bh(&dn_rt_hash_table[hash].lock);
|
|
spin_lock_bh(&dn_rt_hash_table[hash].lock);
|
|
while ((rth = rcu_dereference_protected(*rthp,
|
|
while ((rth = rcu_dereference_protected(*rthp,
|
|
lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) {
|
|
lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) {
|
|
- if (compare_keys(&rth->fl, &rt->fl)) {
|
|
|
|
|
|
+ if (compare_keys(&rth->fld, &rt->fld)) {
|
|
/* Put it first */
|
|
/* Put it first */
|
|
*rthp = rth->dst.dn_next;
|
|
*rthp = rth->dst.dn_next;
|
|
rcu_assign_pointer(rth->dst.dn_next,
|
|
rcu_assign_pointer(rth->dst.dn_next,
|
|
@@ -903,15 +903,15 @@ static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_re
|
|
return (daddr&~mask)|res->fi->fib_nh->nh_gw;
|
|
return (daddr&~mask)|res->fi->fib_nh->nh_gw;
|
|
}
|
|
}
|
|
|
|
|
|
-static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *oldflp, int try_hard)
|
|
|
|
|
|
+static int dn_route_output_slow(struct dst_entry **pprt, const struct flowidn *oldflp, int try_hard)
|
|
{
|
|
{
|
|
- struct flowi fl = {
|
|
|
|
- .fld_dst = oldflp->fld_dst,
|
|
|
|
- .fld_src = oldflp->fld_src,
|
|
|
|
- .fld_scope = RT_SCOPE_UNIVERSE,
|
|
|
|
- .flowi_mark = oldflp->flowi_mark,
|
|
|
|
- .flowi_iif = init_net.loopback_dev->ifindex,
|
|
|
|
- .flowi_oif = oldflp->flowi_oif,
|
|
|
|
|
|
+ struct flowidn fld = {
|
|
|
|
+ .daddr = oldflp->daddr,
|
|
|
|
+ .saddr = oldflp->saddr,
|
|
|
|
+ .flowidn_scope = RT_SCOPE_UNIVERSE,
|
|
|
|
+ .flowidn_mark = oldflp->flowidn_mark,
|
|
|
|
+ .flowidn_iif = init_net.loopback_dev->ifindex,
|
|
|
|
+ .flowidn_oif = oldflp->flowidn_oif,
|
|
};
|
|
};
|
|
struct dn_route *rt = NULL;
|
|
struct dn_route *rt = NULL;
|
|
struct net_device *dev_out = NULL, *dev;
|
|
struct net_device *dev_out = NULL, *dev;
|
|
@@ -926,13 +926,14 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
|
if (decnet_debug_level & 16)
|
|
if (decnet_debug_level & 16)
|
|
printk(KERN_DEBUG
|
|
printk(KERN_DEBUG
|
|
"dn_route_output_slow: dst=%04x src=%04x mark=%d"
|
|
"dn_route_output_slow: dst=%04x src=%04x mark=%d"
|
|
- " iif=%d oif=%d\n", le16_to_cpu(oldflp->fld_dst),
|
|
|
|
- le16_to_cpu(oldflp->fld_src),
|
|
|
|
- oldflp->flowi_mark, init_net.loopback_dev->ifindex, oldflp->flowi_oif);
|
|
|
|
|
|
+ " iif=%d oif=%d\n", le16_to_cpu(oldflp->daddr),
|
|
|
|
+ le16_to_cpu(oldflp->saddr),
|
|
|
|
+ oldflp->flowidn_mark, init_net.loopback_dev->ifindex,
|
|
|
|
+ oldflp->flowidn_oif);
|
|
|
|
|
|
/* If we have an output interface, verify its a DECnet device */
|
|
/* If we have an output interface, verify its a DECnet device */
|
|
- if (oldflp->flowi_oif) {
|
|
|
|
- dev_out = dev_get_by_index(&init_net, oldflp->flowi_oif);
|
|
|
|
|
|
+ if (oldflp->flowidn_oif) {
|
|
|
|
+ dev_out = dev_get_by_index(&init_net, oldflp->flowidn_oif);
|
|
err = -ENODEV;
|
|
err = -ENODEV;
|
|
if (dev_out && dev_out->dn_ptr == NULL) {
|
|
if (dev_out && dev_out->dn_ptr == NULL) {
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
@@ -943,11 +944,11 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
|
}
|
|
}
|
|
|
|
|
|
/* If we have a source address, verify that its a local address */
|
|
/* If we have a source address, verify that its a local address */
|
|
- if (oldflp->fld_src) {
|
|
|
|
|
|
+ if (oldflp->saddr) {
|
|
err = -EADDRNOTAVAIL;
|
|
err = -EADDRNOTAVAIL;
|
|
|
|
|
|
if (dev_out) {
|
|
if (dev_out) {
|
|
- if (dn_dev_islocal(dev_out, oldflp->fld_src))
|
|
|
|
|
|
+ if (dn_dev_islocal(dev_out, oldflp->saddr))
|
|
goto source_ok;
|
|
goto source_ok;
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
goto out;
|
|
goto out;
|
|
@@ -956,11 +957,11 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
|
for_each_netdev_rcu(&init_net, dev) {
|
|
for_each_netdev_rcu(&init_net, dev) {
|
|
if (!dev->dn_ptr)
|
|
if (!dev->dn_ptr)
|
|
continue;
|
|
continue;
|
|
- if (!dn_dev_islocal(dev, oldflp->fld_src))
|
|
|
|
|
|
+ if (!dn_dev_islocal(dev, oldflp->saddr))
|
|
continue;
|
|
continue;
|
|
if ((dev->flags & IFF_LOOPBACK) &&
|
|
if ((dev->flags & IFF_LOOPBACK) &&
|
|
- oldflp->fld_dst &&
|
|
|
|
- !dn_dev_islocal(dev, oldflp->fld_dst))
|
|
|
|
|
|
+ oldflp->daddr &&
|
|
|
|
+ !dn_dev_islocal(dev, oldflp->daddr))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
dev_out = dev;
|
|
dev_out = dev;
|
|
@@ -975,22 +976,22 @@ source_ok:
|
|
}
|
|
}
|
|
|
|
|
|
/* No destination? Assume its local */
|
|
/* No destination? Assume its local */
|
|
- if (!fl.fld_dst) {
|
|
|
|
- fl.fld_dst = fl.fld_src;
|
|
|
|
|
|
+ if (!fld.daddr) {
|
|
|
|
+ fld.daddr = fld.saddr;
|
|
|
|
|
|
err = -EADDRNOTAVAIL;
|
|
err = -EADDRNOTAVAIL;
|
|
if (dev_out)
|
|
if (dev_out)
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
dev_out = init_net.loopback_dev;
|
|
dev_out = init_net.loopback_dev;
|
|
dev_hold(dev_out);
|
|
dev_hold(dev_out);
|
|
- if (!fl.fld_dst) {
|
|
|
|
- fl.fld_dst =
|
|
|
|
- fl.fld_src = dnet_select_source(dev_out, 0,
|
|
|
|
|
|
+ if (!fld.daddr) {
|
|
|
|
+ fld.daddr =
|
|
|
|
+ fld.saddr = dnet_select_source(dev_out, 0,
|
|
RT_SCOPE_HOST);
|
|
RT_SCOPE_HOST);
|
|
- if (!fl.fld_dst)
|
|
|
|
|
|
+ if (!fld.daddr)
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- fl.flowi_oif = init_net.loopback_dev->ifindex;
|
|
|
|
|
|
+ fld.flowidn_oif = init_net.loopback_dev->ifindex;
|
|
res.type = RTN_LOCAL;
|
|
res.type = RTN_LOCAL;
|
|
goto make_route;
|
|
goto make_route;
|
|
}
|
|
}
|
|
@@ -999,8 +1000,8 @@ source_ok:
|
|
printk(KERN_DEBUG
|
|
printk(KERN_DEBUG
|
|
"dn_route_output_slow: initial checks complete."
|
|
"dn_route_output_slow: initial checks complete."
|
|
" dst=%o4x src=%04x oif=%d try_hard=%d\n",
|
|
" dst=%o4x src=%04x oif=%d try_hard=%d\n",
|
|
- le16_to_cpu(fl.fld_dst), le16_to_cpu(fl.fld_src),
|
|
|
|
- fl.flowi_oif, try_hard);
|
|
|
|
|
|
+ le16_to_cpu(fld.daddr), le16_to_cpu(fld.saddr),
|
|
|
|
+ fld.flowidn_oif, try_hard);
|
|
|
|
|
|
/*
|
|
/*
|
|
* N.B. If the kernel is compiled without router support then
|
|
* N.B. If the kernel is compiled without router support then
|
|
@@ -1008,7 +1009,7 @@ source_ok:
|
|
* will always be executed.
|
|
* will always be executed.
|
|
*/
|
|
*/
|
|
err = -ESRCH;
|
|
err = -ESRCH;
|
|
- if (try_hard || (err = dn_fib_lookup(&fl, &res)) != 0) {
|
|
|
|
|
|
+ if (try_hard || (err = dn_fib_lookup(&fld, &res)) != 0) {
|
|
struct dn_dev *dn_db;
|
|
struct dn_dev *dn_db;
|
|
if (err != -ESRCH)
|
|
if (err != -ESRCH)
|
|
goto out;
|
|
goto out;
|
|
@@ -1023,19 +1024,19 @@ source_ok:
|
|
* here
|
|
* here
|
|
*/
|
|
*/
|
|
if (!try_hard) {
|
|
if (!try_hard) {
|
|
- neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fl.fld_dst);
|
|
|
|
|
|
+ neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fld.daddr);
|
|
if (neigh) {
|
|
if (neigh) {
|
|
- if ((oldflp->flowi_oif &&
|
|
|
|
- (neigh->dev->ifindex != oldflp->flowi_oif)) ||
|
|
|
|
- (oldflp->fld_src &&
|
|
|
|
|
|
+ if ((oldflp->flowidn_oif &&
|
|
|
|
+ (neigh->dev->ifindex != oldflp->flowidn_oif)) ||
|
|
|
|
+ (oldflp->saddr &&
|
|
(!dn_dev_islocal(neigh->dev,
|
|
(!dn_dev_islocal(neigh->dev,
|
|
- oldflp->fld_src)))) {
|
|
|
|
|
|
+ oldflp->saddr)))) {
|
|
neigh_release(neigh);
|
|
neigh_release(neigh);
|
|
neigh = NULL;
|
|
neigh = NULL;
|
|
} else {
|
|
} else {
|
|
if (dev_out)
|
|
if (dev_out)
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
- if (dn_dev_islocal(neigh->dev, fl.fld_dst)) {
|
|
|
|
|
|
+ if (dn_dev_islocal(neigh->dev, fld.daddr)) {
|
|
dev_out = init_net.loopback_dev;
|
|
dev_out = init_net.loopback_dev;
|
|
res.type = RTN_LOCAL;
|
|
res.type = RTN_LOCAL;
|
|
} else {
|
|
} else {
|
|
@@ -1055,7 +1056,7 @@ source_ok:
|
|
goto out;
|
|
goto out;
|
|
dn_db = rcu_dereference_raw(dev_out->dn_ptr);
|
|
dn_db = rcu_dereference_raw(dev_out->dn_ptr);
|
|
/* Possible improvement - check all devices for local addr */
|
|
/* Possible improvement - check all devices for local addr */
|
|
- if (dn_dev_islocal(dev_out, fl.fld_dst)) {
|
|
|
|
|
|
+ if (dn_dev_islocal(dev_out, fld.daddr)) {
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
dev_out = init_net.loopback_dev;
|
|
dev_out = init_net.loopback_dev;
|
|
dev_hold(dev_out);
|
|
dev_hold(dev_out);
|
|
@@ -1071,16 +1072,16 @@ select_source:
|
|
if (neigh)
|
|
if (neigh)
|
|
gateway = ((struct dn_neigh *)neigh)->addr;
|
|
gateway = ((struct dn_neigh *)neigh)->addr;
|
|
if (gateway == 0)
|
|
if (gateway == 0)
|
|
- gateway = fl.fld_dst;
|
|
|
|
- if (fl.fld_src == 0) {
|
|
|
|
- fl.fld_src = dnet_select_source(dev_out, gateway,
|
|
|
|
- res.type == RTN_LOCAL ?
|
|
|
|
- RT_SCOPE_HOST :
|
|
|
|
- RT_SCOPE_LINK);
|
|
|
|
- if (fl.fld_src == 0 && res.type != RTN_LOCAL)
|
|
|
|
|
|
+ gateway = fld.daddr;
|
|
|
|
+ if (fld.saddr == 0) {
|
|
|
|
+ fld.saddr = dnet_select_source(dev_out, gateway,
|
|
|
|
+ res.type == RTN_LOCAL ?
|
|
|
|
+ RT_SCOPE_HOST :
|
|
|
|
+ RT_SCOPE_LINK);
|
|
|
|
+ if (fld.saddr == 0 && res.type != RTN_LOCAL)
|
|
goto e_addr;
|
|
goto e_addr;
|
|
}
|
|
}
|
|
- fl.flowi_oif = dev_out->ifindex;
|
|
|
|
|
|
+ fld.flowidn_oif = dev_out->ifindex;
|
|
goto make_route;
|
|
goto make_route;
|
|
}
|
|
}
|
|
free_res = 1;
|
|
free_res = 1;
|
|
@@ -1089,35 +1090,35 @@ select_source:
|
|
goto e_inval;
|
|
goto e_inval;
|
|
|
|
|
|
if (res.type == RTN_LOCAL) {
|
|
if (res.type == RTN_LOCAL) {
|
|
- if (!fl.fld_src)
|
|
|
|
- fl.fld_src = fl.fld_dst;
|
|
|
|
|
|
+ if (!fld.saddr)
|
|
|
|
+ fld.saddr = fld.daddr;
|
|
if (dev_out)
|
|
if (dev_out)
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
dev_out = init_net.loopback_dev;
|
|
dev_out = init_net.loopback_dev;
|
|
dev_hold(dev_out);
|
|
dev_hold(dev_out);
|
|
- fl.flowi_oif = dev_out->ifindex;
|
|
|
|
|
|
+ fld.flowidn_oif = dev_out->ifindex;
|
|
if (res.fi)
|
|
if (res.fi)
|
|
dn_fib_info_put(res.fi);
|
|
dn_fib_info_put(res.fi);
|
|
res.fi = NULL;
|
|
res.fi = NULL;
|
|
goto make_route;
|
|
goto make_route;
|
|
}
|
|
}
|
|
|
|
|
|
- if (res.fi->fib_nhs > 1 && fl.flowi_oif == 0)
|
|
|
|
- dn_fib_select_multipath(&fl, &res);
|
|
|
|
|
|
+ if (res.fi->fib_nhs > 1 && fld.flowidn_oif == 0)
|
|
|
|
+ dn_fib_select_multipath(&fld, &res);
|
|
|
|
|
|
/*
|
|
/*
|
|
* We could add some logic to deal with default routes here and
|
|
* We could add some logic to deal with default routes here and
|
|
* get rid of some of the special casing above.
|
|
* get rid of some of the special casing above.
|
|
*/
|
|
*/
|
|
|
|
|
|
- if (!fl.fld_src)
|
|
|
|
- fl.fld_src = DN_FIB_RES_PREFSRC(res);
|
|
|
|
|
|
+ if (!fld.saddr)
|
|
|
|
+ fld.saddr = DN_FIB_RES_PREFSRC(res);
|
|
|
|
|
|
if (dev_out)
|
|
if (dev_out)
|
|
dev_put(dev_out);
|
|
dev_put(dev_out);
|
|
dev_out = DN_FIB_RES_DEV(res);
|
|
dev_out = DN_FIB_RES_DEV(res);
|
|
dev_hold(dev_out);
|
|
dev_hold(dev_out);
|
|
- fl.flowi_oif = dev_out->ifindex;
|
|
|
|
|
|
+ fld.flowidn_oif = dev_out->ifindex;
|
|
gateway = DN_FIB_RES_GW(res);
|
|
gateway = DN_FIB_RES_GW(res);
|
|
|
|
|
|
make_route:
|
|
make_route:
|
|
@@ -1131,19 +1132,19 @@ make_route:
|
|
atomic_set(&rt->dst.__refcnt, 1);
|
|
atomic_set(&rt->dst.__refcnt, 1);
|
|
rt->dst.flags = DST_HOST;
|
|
rt->dst.flags = DST_HOST;
|
|
|
|
|
|
- rt->fl.fld_src = oldflp->fld_src;
|
|
|
|
- rt->fl.fld_dst = oldflp->fld_dst;
|
|
|
|
- rt->fl.flowi_oif = oldflp->flowi_oif;
|
|
|
|
- rt->fl.flowi_iif = 0;
|
|
|
|
- rt->fl.flowi_mark = oldflp->flowi_mark;
|
|
|
|
|
|
+ rt->fld.saddr = oldflp->saddr;
|
|
|
|
+ rt->fld.daddr = oldflp->daddr;
|
|
|
|
+ rt->fld.flowidn_oif = oldflp->flowidn_oif;
|
|
|
|
+ rt->fld.flowidn_iif = 0;
|
|
|
|
+ rt->fld.flowidn_mark = oldflp->flowidn_mark;
|
|
|
|
|
|
- rt->rt_saddr = fl.fld_src;
|
|
|
|
- rt->rt_daddr = fl.fld_dst;
|
|
|
|
- rt->rt_gateway = gateway ? gateway : fl.fld_dst;
|
|
|
|
- rt->rt_local_src = fl.fld_src;
|
|
|
|
|
|
+ rt->rt_saddr = fld.saddr;
|
|
|
|
+ rt->rt_daddr = fld.daddr;
|
|
|
|
+ rt->rt_gateway = gateway ? gateway : fld.daddr;
|
|
|
|
+ rt->rt_local_src = fld.saddr;
|
|
|
|
|
|
- rt->rt_dst_map = fl.fld_dst;
|
|
|
|
- rt->rt_src_map = fl.fld_src;
|
|
|
|
|
|
+ rt->rt_dst_map = fld.daddr;
|
|
|
|
+ rt->rt_src_map = fld.saddr;
|
|
|
|
|
|
rt->dst.dev = dev_out;
|
|
rt->dst.dev = dev_out;
|
|
dev_hold(dev_out);
|
|
dev_hold(dev_out);
|
|
@@ -1161,7 +1162,7 @@ make_route:
|
|
if (err)
|
|
if (err)
|
|
goto e_neighbour;
|
|
goto e_neighbour;
|
|
|
|
|
|
- hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst);
|
|
|
|
|
|
+ hash = dn_hash(rt->fld.saddr, rt->fld.daddr);
|
|
dn_insert_route(rt, hash, (struct dn_route **)pprt);
|
|
dn_insert_route(rt, hash, (struct dn_route **)pprt);
|
|
|
|
|
|
done:
|
|
done:
|
|
@@ -1192,20 +1193,20 @@ e_neighbour:
|
|
/*
|
|
/*
|
|
* N.B. The flags may be moved into the flowi at some future stage.
|
|
* N.B. The flags may be moved into the flowi at some future stage.
|
|
*/
|
|
*/
|
|
-static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *flp, int flags)
|
|
|
|
|
|
+static int __dn_route_output_key(struct dst_entry **pprt, const struct flowidn *flp, int flags)
|
|
{
|
|
{
|
|
- unsigned hash = dn_hash(flp->fld_src, flp->fld_dst);
|
|
|
|
|
|
+ unsigned hash = dn_hash(flp->saddr, flp->daddr);
|
|
struct dn_route *rt = NULL;
|
|
struct dn_route *rt = NULL;
|
|
|
|
|
|
if (!(flags & MSG_TRYHARD)) {
|
|
if (!(flags & MSG_TRYHARD)) {
|
|
rcu_read_lock_bh();
|
|
rcu_read_lock_bh();
|
|
for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt;
|
|
for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt;
|
|
rt = rcu_dereference_bh(rt->dst.dn_next)) {
|
|
rt = rcu_dereference_bh(rt->dst.dn_next)) {
|
|
- if ((flp->fld_dst == rt->fl.fld_dst) &&
|
|
|
|
- (flp->fld_src == rt->fl.fld_src) &&
|
|
|
|
- (flp->flowi_mark == rt->fl.flowi_mark) &&
|
|
|
|
|
|
+ if ((flp->daddr == rt->fld.daddr) &&
|
|
|
|
+ (flp->saddr == rt->fld.saddr) &&
|
|
|
|
+ (flp->flowidn_mark == rt->fld.flowidn_mark) &&
|
|
dn_is_output_route(rt) &&
|
|
dn_is_output_route(rt) &&
|
|
- (rt->fl.flowi_oif == flp->flowi_oif)) {
|
|
|
|
|
|
+ (rt->fld.flowidn_oif == flp->flowidn_oif)) {
|
|
dst_use(&rt->dst, jiffies);
|
|
dst_use(&rt->dst, jiffies);
|
|
rcu_read_unlock_bh();
|
|
rcu_read_unlock_bh();
|
|
*pprt = &rt->dst;
|
|
*pprt = &rt->dst;
|
|
@@ -1218,13 +1219,14 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
|
|
return dn_route_output_slow(pprt, flp, flags);
|
|
return dn_route_output_slow(pprt, flp, flags);
|
|
}
|
|
}
|
|
|
|
|
|
-static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int flags)
|
|
|
|
|
|
+static int dn_route_output_key(struct dst_entry **pprt, struct flowidn *flp, int flags)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
|
|
|
|
err = __dn_route_output_key(pprt, flp, flags);
|
|
err = __dn_route_output_key(pprt, flp, flags);
|
|
- if (err == 0 && flp->flowi_proto) {
|
|
|
|
- *pprt = xfrm_lookup(&init_net, *pprt, flp, NULL, 0);
|
|
|
|
|
|
+ if (err == 0 && flp->flowidn_proto) {
|
|
|
|
+ *pprt = xfrm_lookup(&init_net, *pprt,
|
|
|
|
+ flowidn_to_flowi(flp), NULL, 0);
|
|
if (IS_ERR(*pprt)) {
|
|
if (IS_ERR(*pprt)) {
|
|
err = PTR_ERR(*pprt);
|
|
err = PTR_ERR(*pprt);
|
|
*pprt = NULL;
|
|
*pprt = NULL;
|
|
@@ -1233,15 +1235,16 @@ static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int f
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
-int dn_route_output_sock(struct dst_entry **pprt, struct flowi *fl, struct sock *sk, int flags)
|
|
|
|
|
|
+int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *fl, struct sock *sk, int flags)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
|
|
|
|
err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD);
|
|
err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD);
|
|
- if (err == 0 && fl->flowi_proto) {
|
|
|
|
|
|
+ if (err == 0 && fl->flowidn_proto) {
|
|
if (!(flags & MSG_DONTWAIT))
|
|
if (!(flags & MSG_DONTWAIT))
|
|
- fl->flowi_flags |= FLOWI_FLAG_CAN_SLEEP;
|
|
|
|
- *pprt = xfrm_lookup(&init_net, *pprt, fl, sk, 0);
|
|
|
|
|
|
+ fl->flowidn_flags |= FLOWI_FLAG_CAN_SLEEP;
|
|
|
|
+ *pprt = xfrm_lookup(&init_net, *pprt,
|
|
|
|
+ flowidn_to_flowi(fl), sk, 0);
|
|
if (IS_ERR(*pprt)) {
|
|
if (IS_ERR(*pprt)) {
|
|
err = PTR_ERR(*pprt);
|
|
err = PTR_ERR(*pprt);
|
|
*pprt = NULL;
|
|
*pprt = NULL;
|
|
@@ -1262,12 +1265,12 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
int flags = 0;
|
|
int flags = 0;
|
|
__le16 gateway = 0;
|
|
__le16 gateway = 0;
|
|
__le16 local_src = 0;
|
|
__le16 local_src = 0;
|
|
- struct flowi fl = {
|
|
|
|
- .fld_dst = cb->dst,
|
|
|
|
- .fld_src = cb->src,
|
|
|
|
- .fld_scope = RT_SCOPE_UNIVERSE,
|
|
|
|
- .flowi_mark = skb->mark,
|
|
|
|
- .flowi_iif = skb->dev->ifindex,
|
|
|
|
|
|
+ struct flowidn fld = {
|
|
|
|
+ .daddr = cb->dst,
|
|
|
|
+ .saddr = cb->src,
|
|
|
|
+ .flowidn_scope = RT_SCOPE_UNIVERSE,
|
|
|
|
+ .flowidn_mark = skb->mark,
|
|
|
|
+ .flowidn_iif = skb->dev->ifindex,
|
|
};
|
|
};
|
|
struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE };
|
|
struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE };
|
|
int err = -EINVAL;
|
|
int err = -EINVAL;
|
|
@@ -1279,7 +1282,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
/* Zero source addresses are not allowed */
|
|
/* Zero source addresses are not allowed */
|
|
- if (fl.fld_src == 0)
|
|
|
|
|
|
+ if (fld.saddr == 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1293,7 +1296,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
if (dn_dev_islocal(in_dev, cb->src))
|
|
if (dn_dev_islocal(in_dev, cb->src))
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- err = dn_fib_lookup(&fl, &res);
|
|
|
|
|
|
+ err = dn_fib_lookup(&fld, &res);
|
|
if (err) {
|
|
if (err) {
|
|
if (err != -ESRCH)
|
|
if (err != -ESRCH)
|
|
goto out;
|
|
goto out;
|
|
@@ -1305,7 +1308,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
|
|
|
|
res.type = RTN_LOCAL;
|
|
res.type = RTN_LOCAL;
|
|
} else {
|
|
} else {
|
|
- __le16 src_map = fl.fld_src;
|
|
|
|
|
|
+ __le16 src_map = fld.saddr;
|
|
free_res = 1;
|
|
free_res = 1;
|
|
|
|
|
|
out_dev = DN_FIB_RES_DEV(res);
|
|
out_dev = DN_FIB_RES_DEV(res);
|
|
@@ -1318,22 +1321,22 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
dev_hold(out_dev);
|
|
dev_hold(out_dev);
|
|
|
|
|
|
if (res.r)
|
|
if (res.r)
|
|
- src_map = fl.fld_src; /* no NAT support for now */
|
|
|
|
|
|
+ src_map = fld.saddr; /* no NAT support for now */
|
|
|
|
|
|
gateway = DN_FIB_RES_GW(res);
|
|
gateway = DN_FIB_RES_GW(res);
|
|
if (res.type == RTN_NAT) {
|
|
if (res.type == RTN_NAT) {
|
|
- fl.fld_dst = dn_fib_rules_map_destination(fl.fld_dst, &res);
|
|
|
|
|
|
+ fld.daddr = dn_fib_rules_map_destination(fld.daddr, &res);
|
|
dn_fib_res_put(&res);
|
|
dn_fib_res_put(&res);
|
|
free_res = 0;
|
|
free_res = 0;
|
|
- if (dn_fib_lookup(&fl, &res))
|
|
|
|
|
|
+ if (dn_fib_lookup(&fld, &res))
|
|
goto e_inval;
|
|
goto e_inval;
|
|
free_res = 1;
|
|
free_res = 1;
|
|
if (res.type != RTN_UNICAST)
|
|
if (res.type != RTN_UNICAST)
|
|
goto e_inval;
|
|
goto e_inval;
|
|
flags |= RTCF_DNAT;
|
|
flags |= RTCF_DNAT;
|
|
- gateway = fl.fld_dst;
|
|
|
|
|
|
+ gateway = fld.daddr;
|
|
}
|
|
}
|
|
- fl.fld_src = src_map;
|
|
|
|
|
|
+ fld.saddr = src_map;
|
|
}
|
|
}
|
|
|
|
|
|
switch(res.type) {
|
|
switch(res.type) {
|
|
@@ -1347,8 +1350,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
if (dn_db->parms.forwarding == 0)
|
|
if (dn_db->parms.forwarding == 0)
|
|
goto e_inval;
|
|
goto e_inval;
|
|
|
|
|
|
- if (res.fi->fib_nhs > 1 && fl.flowi_oif == 0)
|
|
|
|
- dn_fib_select_multipath(&fl, &res);
|
|
|
|
|
|
+ if (res.fi->fib_nhs > 1 && fld.flowidn_oif == 0)
|
|
|
|
+ dn_fib_select_multipath(&fld, &res);
|
|
|
|
|
|
/*
|
|
/*
|
|
* Check for out_dev == in_dev. We use the RTCF_DOREDIRECT
|
|
* Check for out_dev == in_dev. We use the RTCF_DOREDIRECT
|
|
@@ -1366,8 +1369,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
|
|
break;
|
|
break;
|
|
case RTN_LOCAL:
|
|
case RTN_LOCAL:
|
|
flags |= RTCF_LOCAL;
|
|
flags |= RTCF_LOCAL;
|
|
- fl.fld_src = cb->dst;
|
|
|
|
- fl.fld_dst = cb->src;
|
|
|
|
|
|
+ fld.saddr = cb->dst;
|
|
|
|
+ fld.daddr = cb->src;
|
|
|
|
|
|
/* Routing tables gave us a gateway */
|
|
/* Routing tables gave us a gateway */
|
|
if (gateway)
|
|
if (gateway)
|
|
@@ -1400,21 +1403,21 @@ make_route:
|
|
if (rt == NULL)
|
|
if (rt == NULL)
|
|
goto e_nobufs;
|
|
goto e_nobufs;
|
|
|
|
|
|
- rt->rt_saddr = fl.fld_src;
|
|
|
|
- rt->rt_daddr = fl.fld_dst;
|
|
|
|
- rt->rt_gateway = fl.fld_dst;
|
|
|
|
|
|
+ rt->rt_saddr = fld.saddr;
|
|
|
|
+ rt->rt_daddr = fld.daddr;
|
|
|
|
+ rt->rt_gateway = fld.daddr;
|
|
if (gateway)
|
|
if (gateway)
|
|
rt->rt_gateway = gateway;
|
|
rt->rt_gateway = gateway;
|
|
rt->rt_local_src = local_src ? local_src : rt->rt_saddr;
|
|
rt->rt_local_src = local_src ? local_src : rt->rt_saddr;
|
|
|
|
|
|
- rt->rt_dst_map = fl.fld_dst;
|
|
|
|
- rt->rt_src_map = fl.fld_src;
|
|
|
|
|
|
+ rt->rt_dst_map = fld.daddr;
|
|
|
|
+ rt->rt_src_map = fld.saddr;
|
|
|
|
|
|
- rt->fl.fld_src = cb->src;
|
|
|
|
- rt->fl.fld_dst = cb->dst;
|
|
|
|
- rt->fl.flowi_oif = 0;
|
|
|
|
- rt->fl.flowi_iif = in_dev->ifindex;
|
|
|
|
- rt->fl.flowi_mark = fl.flowi_mark;
|
|
|
|
|
|
+ rt->fld.saddr = cb->src;
|
|
|
|
+ rt->fld.daddr = cb->dst;
|
|
|
|
+ rt->fld.flowidn_oif = 0;
|
|
|
|
+ rt->fld.flowidn_iif = in_dev->ifindex;
|
|
|
|
+ rt->fld.flowidn_mark = fld.flowidn_mark;
|
|
|
|
|
|
rt->dst.flags = DST_HOST;
|
|
rt->dst.flags = DST_HOST;
|
|
rt->dst.neighbour = neigh;
|
|
rt->dst.neighbour = neigh;
|
|
@@ -1444,7 +1447,7 @@ make_route:
|
|
if (err)
|
|
if (err)
|
|
goto e_neighbour;
|
|
goto e_neighbour;
|
|
|
|
|
|
- hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst);
|
|
|
|
|
|
+ hash = dn_hash(rt->fld.saddr, rt->fld.daddr);
|
|
dn_insert_route(rt, hash, &rt);
|
|
dn_insert_route(rt, hash, &rt);
|
|
skb_dst_set(skb, &rt->dst);
|
|
skb_dst_set(skb, &rt->dst);
|
|
|
|
|
|
@@ -1484,11 +1487,11 @@ static int dn_route_input(struct sk_buff *skb)
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
|
|
for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
|
|
rt = rcu_dereference(rt->dst.dn_next)) {
|
|
rt = rcu_dereference(rt->dst.dn_next)) {
|
|
- if ((rt->fl.fld_src == cb->src) &&
|
|
|
|
- (rt->fl.fld_dst == cb->dst) &&
|
|
|
|
- (rt->fl.flowi_oif == 0) &&
|
|
|
|
- (rt->fl.flowi_mark == skb->mark) &&
|
|
|
|
- (rt->fl.flowi_iif == cb->iif)) {
|
|
|
|
|
|
+ if ((rt->fld.saddr == cb->src) &&
|
|
|
|
+ (rt->fld.daddr == cb->dst) &&
|
|
|
|
+ (rt->fld.flowidn_oif == 0) &&
|
|
|
|
+ (rt->fld.flowidn_mark == skb->mark) &&
|
|
|
|
+ (rt->fld.flowidn_iif == cb->iif)) {
|
|
dst_use(&rt->dst, jiffies);
|
|
dst_use(&rt->dst, jiffies);
|
|
rcu_read_unlock();
|
|
rcu_read_unlock();
|
|
skb_dst_set(skb, (struct dst_entry *)rt);
|
|
skb_dst_set(skb, (struct dst_entry *)rt);
|
|
@@ -1524,9 +1527,9 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
|
|
if (rt->rt_flags & RTCF_NOTIFY)
|
|
if (rt->rt_flags & RTCF_NOTIFY)
|
|
r->rtm_flags |= RTM_F_NOTIFY;
|
|
r->rtm_flags |= RTM_F_NOTIFY;
|
|
RTA_PUT(skb, RTA_DST, 2, &rt->rt_daddr);
|
|
RTA_PUT(skb, RTA_DST, 2, &rt->rt_daddr);
|
|
- if (rt->fl.fld_src) {
|
|
|
|
|
|
+ if (rt->fld.saddr) {
|
|
r->rtm_src_len = 16;
|
|
r->rtm_src_len = 16;
|
|
- RTA_PUT(skb, RTA_SRC, 2, &rt->fl.fld_src);
|
|
|
|
|
|
+ RTA_PUT(skb, RTA_SRC, 2, &rt->fld.saddr);
|
|
}
|
|
}
|
|
if (rt->dst.dev)
|
|
if (rt->dst.dev)
|
|
RTA_PUT(skb, RTA_OIF, sizeof(int), &rt->dst.dev->ifindex);
|
|
RTA_PUT(skb, RTA_OIF, sizeof(int), &rt->dst.dev->ifindex);
|
|
@@ -1545,7 +1548,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
|
|
rt->dst.error) < 0)
|
|
rt->dst.error) < 0)
|
|
goto rtattr_failure;
|
|
goto rtattr_failure;
|
|
if (dn_is_input_route(rt))
|
|
if (dn_is_input_route(rt))
|
|
- RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.flowi_iif);
|
|
|
|
|
|
+ RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fld.flowidn_iif);
|
|
|
|
|
|
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
|
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
|
return skb->len;
|
|
return skb->len;
|
|
@@ -1568,13 +1571,13 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
|
|
struct dn_skb_cb *cb;
|
|
struct dn_skb_cb *cb;
|
|
int err;
|
|
int err;
|
|
struct sk_buff *skb;
|
|
struct sk_buff *skb;
|
|
- struct flowi fl;
|
|
|
|
|
|
+ struct flowidn fld;
|
|
|
|
|
|
if (!net_eq(net, &init_net))
|
|
if (!net_eq(net, &init_net))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
- memset(&fl, 0, sizeof(fl));
|
|
|
|
- fl.flowi_proto = DNPROTO_NSP;
|
|
|
|
|
|
+ memset(&fld, 0, sizeof(fld));
|
|
|
|
+ fld.flowidn_proto = DNPROTO_NSP;
|
|
|
|
|
|
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
|
|
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
|
|
if (skb == NULL)
|
|
if (skb == NULL)
|
|
@@ -1583,15 +1586,15 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
|
|
cb = DN_SKB_CB(skb);
|
|
cb = DN_SKB_CB(skb);
|
|
|
|
|
|
if (rta[RTA_SRC-1])
|
|
if (rta[RTA_SRC-1])
|
|
- memcpy(&fl.fld_src, RTA_DATA(rta[RTA_SRC-1]), 2);
|
|
|
|
|
|
+ memcpy(&fld.saddr, RTA_DATA(rta[RTA_SRC-1]), 2);
|
|
if (rta[RTA_DST-1])
|
|
if (rta[RTA_DST-1])
|
|
- memcpy(&fl.fld_dst, RTA_DATA(rta[RTA_DST-1]), 2);
|
|
|
|
|
|
+ memcpy(&fld.daddr, RTA_DATA(rta[RTA_DST-1]), 2);
|
|
if (rta[RTA_IIF-1])
|
|
if (rta[RTA_IIF-1])
|
|
- memcpy(&fl.flowi_iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int));
|
|
|
|
|
|
+ memcpy(&fld.flowidn_iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int));
|
|
|
|
|
|
- if (fl.flowi_iif) {
|
|
|
|
|
|
+ if (fld.flowidn_iif) {
|
|
struct net_device *dev;
|
|
struct net_device *dev;
|
|
- if ((dev = dev_get_by_index(&init_net, fl.flowi_iif)) == NULL) {
|
|
|
|
|
|
+ if ((dev = dev_get_by_index(&init_net, fld.flowidn_iif)) == NULL) {
|
|
kfree_skb(skb);
|
|
kfree_skb(skb);
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
@@ -1602,8 +1605,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
|
|
}
|
|
}
|
|
skb->protocol = htons(ETH_P_DNA_RT);
|
|
skb->protocol = htons(ETH_P_DNA_RT);
|
|
skb->dev = dev;
|
|
skb->dev = dev;
|
|
- cb->src = fl.fld_src;
|
|
|
|
- cb->dst = fl.fld_dst;
|
|
|
|
|
|
+ cb->src = fld.saddr;
|
|
|
|
+ cb->dst = fld.daddr;
|
|
local_bh_disable();
|
|
local_bh_disable();
|
|
err = dn_route_input(skb);
|
|
err = dn_route_input(skb);
|
|
local_bh_enable();
|
|
local_bh_enable();
|
|
@@ -1615,8 +1618,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
|
|
int oif = 0;
|
|
int oif = 0;
|
|
if (rta[RTA_OIF - 1])
|
|
if (rta[RTA_OIF - 1])
|
|
memcpy(&oif, RTA_DATA(rta[RTA_OIF - 1]), sizeof(int));
|
|
memcpy(&oif, RTA_DATA(rta[RTA_OIF - 1]), sizeof(int));
|
|
- fl.flowi_oif = oif;
|
|
|
|
- err = dn_route_output_key((struct dst_entry **)&rt, &fl, 0);
|
|
|
|
|
|
+ fld.flowidn_oif = oif;
|
|
|
|
+ err = dn_route_output_key((struct dst_entry **)&rt, &fld, 0);
|
|
}
|
|
}
|
|
|
|
|
|
if (skb->dev)
|
|
if (skb->dev)
|