diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-12 17:17:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-12 18:08:55 -0500 |
commit | bef55aebd560c5a6f8883c421abccee39978c58c (patch) | |
tree | b1adbe59af8817ee6ef3009fe8c296d3c87fc067 /net/decnet/dn_route.c | |
parent | 1958b856c1a59c0f1e892b92debb8c9fe4f364dc (diff) |
decnet: Convert to use flowidn where applicable.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet/dn_route.c')
-rw-r--r-- | net/decnet/dn_route.c | 269 |
1 files changed, 136 insertions, 133 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index d74d34b93f80..9f09d4fc2880 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -282,14 +282,14 @@ static void dn_dst_link_failure(struct sk_buff *skb) | |||
282 | { | 282 | { |
283 | } | 283 | } |
284 | 284 | ||
285 | static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) | 285 | static inline int compare_keys(struct flowidn *fl1, struct flowidn *fl2) |
286 | { | 286 | { |
287 | return ((fl1->fld_dst ^ fl2->fld_dst) | | 287 | return ((fl1->daddr ^ fl2->daddr) | |
288 | (fl1->fld_src ^ fl2->fld_src) | | 288 | (fl1->saddr ^ fl2->saddr) | |
289 | (fl1->flowi_mark ^ fl2->flowi_mark) | | 289 | (fl1->flowidn_mark ^ fl2->flowidn_mark) | |
290 | (fl1->fld_scope ^ fl2->fld_scope) | | 290 | (fl1->flowidn_scope ^ fl2->flowidn_scope) | |
291 | (fl1->flowi_oif ^ fl2->flowi_oif) | | 291 | (fl1->flowidn_oif ^ fl2->flowidn_oif) | |
292 | (fl1->flowi_iif ^ fl2->flowi_iif)) == 0; | 292 | (fl1->flowidn_iif ^ fl2->flowidn_iif)) == 0; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route **rp) | 295 | 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 * | |||
303 | spin_lock_bh(&dn_rt_hash_table[hash].lock); | 303 | spin_lock_bh(&dn_rt_hash_table[hash].lock); |
304 | while ((rth = rcu_dereference_protected(*rthp, | 304 | while ((rth = rcu_dereference_protected(*rthp, |
305 | lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) { | 305 | lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) { |
306 | if (compare_keys(&rth->fl, &rt->fl)) { | 306 | if (compare_keys(&rth->fld, &rt->fld)) { |
307 | /* Put it first */ | 307 | /* Put it first */ |
308 | *rthp = rth->dst.dn_next; | 308 | *rthp = rth->dst.dn_next; |
309 | rcu_assign_pointer(rth->dst.dn_next, | 309 | 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 | |||
903 | return (daddr&~mask)|res->fi->fib_nh->nh_gw; | 903 | return (daddr&~mask)|res->fi->fib_nh->nh_gw; |
904 | } | 904 | } |
905 | 905 | ||
906 | static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *oldflp, int try_hard) | 906 | static int dn_route_output_slow(struct dst_entry **pprt, const struct flowidn *oldflp, int try_hard) |
907 | { | 907 | { |
908 | struct flowi fl = { | 908 | struct flowidn fld = { |
909 | .fld_dst = oldflp->fld_dst, | 909 | .daddr = oldflp->daddr, |
910 | .fld_src = oldflp->fld_src, | 910 | .saddr = oldflp->saddr, |
911 | .fld_scope = RT_SCOPE_UNIVERSE, | 911 | .flowidn_scope = RT_SCOPE_UNIVERSE, |
912 | .flowi_mark = oldflp->flowi_mark, | 912 | .flowidn_mark = oldflp->flowidn_mark, |
913 | .flowi_iif = init_net.loopback_dev->ifindex, | 913 | .flowidn_iif = init_net.loopback_dev->ifindex, |
914 | .flowi_oif = oldflp->flowi_oif, | 914 | .flowidn_oif = oldflp->flowidn_oif, |
915 | }; | 915 | }; |
916 | struct dn_route *rt = NULL; | 916 | struct dn_route *rt = NULL; |
917 | struct net_device *dev_out = NULL, *dev; | 917 | 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 | |||
926 | if (decnet_debug_level & 16) | 926 | if (decnet_debug_level & 16) |
927 | printk(KERN_DEBUG | 927 | printk(KERN_DEBUG |
928 | "dn_route_output_slow: dst=%04x src=%04x mark=%d" | 928 | "dn_route_output_slow: dst=%04x src=%04x mark=%d" |
929 | " iif=%d oif=%d\n", le16_to_cpu(oldflp->fld_dst), | 929 | " iif=%d oif=%d\n", le16_to_cpu(oldflp->daddr), |
930 | le16_to_cpu(oldflp->fld_src), | 930 | le16_to_cpu(oldflp->saddr), |
931 | oldflp->flowi_mark, init_net.loopback_dev->ifindex, oldflp->flowi_oif); | 931 | oldflp->flowidn_mark, init_net.loopback_dev->ifindex, |
932 | oldflp->flowidn_oif); | ||
932 | 933 | ||
933 | /* If we have an output interface, verify its a DECnet device */ | 934 | /* If we have an output interface, verify its a DECnet device */ |
934 | if (oldflp->flowi_oif) { | 935 | if (oldflp->flowidn_oif) { |
935 | dev_out = dev_get_by_index(&init_net, oldflp->flowi_oif); | 936 | dev_out = dev_get_by_index(&init_net, oldflp->flowidn_oif); |
936 | err = -ENODEV; | 937 | err = -ENODEV; |
937 | if (dev_out && dev_out->dn_ptr == NULL) { | 938 | if (dev_out && dev_out->dn_ptr == NULL) { |
938 | dev_put(dev_out); | 939 | dev_put(dev_out); |
@@ -943,11 +944,11 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old | |||
943 | } | 944 | } |
944 | 945 | ||
945 | /* If we have a source address, verify that its a local address */ | 946 | /* If we have a source address, verify that its a local address */ |
946 | if (oldflp->fld_src) { | 947 | if (oldflp->saddr) { |
947 | err = -EADDRNOTAVAIL; | 948 | err = -EADDRNOTAVAIL; |
948 | 949 | ||
949 | if (dev_out) { | 950 | if (dev_out) { |
950 | if (dn_dev_islocal(dev_out, oldflp->fld_src)) | 951 | if (dn_dev_islocal(dev_out, oldflp->saddr)) |
951 | goto source_ok; | 952 | goto source_ok; |
952 | dev_put(dev_out); | 953 | dev_put(dev_out); |
953 | goto out; | 954 | goto out; |
@@ -956,11 +957,11 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old | |||
956 | for_each_netdev_rcu(&init_net, dev) { | 957 | for_each_netdev_rcu(&init_net, dev) { |
957 | if (!dev->dn_ptr) | 958 | if (!dev->dn_ptr) |
958 | continue; | 959 | continue; |
959 | if (!dn_dev_islocal(dev, oldflp->fld_src)) | 960 | if (!dn_dev_islocal(dev, oldflp->saddr)) |
960 | continue; | 961 | continue; |
961 | if ((dev->flags & IFF_LOOPBACK) && | 962 | if ((dev->flags & IFF_LOOPBACK) && |
962 | oldflp->fld_dst && | 963 | oldflp->daddr && |
963 | !dn_dev_islocal(dev, oldflp->fld_dst)) | 964 | !dn_dev_islocal(dev, oldflp->daddr)) |
964 | continue; | 965 | continue; |
965 | 966 | ||
966 | dev_out = dev; | 967 | dev_out = dev; |
@@ -975,22 +976,22 @@ source_ok: | |||
975 | } | 976 | } |
976 | 977 | ||
977 | /* No destination? Assume its local */ | 978 | /* No destination? Assume its local */ |
978 | if (!fl.fld_dst) { | 979 | if (!fld.daddr) { |
979 | fl.fld_dst = fl.fld_src; | 980 | fld.daddr = fld.saddr; |
980 | 981 | ||
981 | err = -EADDRNOTAVAIL; | 982 | err = -EADDRNOTAVAIL; |
982 | if (dev_out) | 983 | if (dev_out) |
983 | dev_put(dev_out); | 984 | dev_put(dev_out); |
984 | dev_out = init_net.loopback_dev; | 985 | dev_out = init_net.loopback_dev; |
985 | dev_hold(dev_out); | 986 | dev_hold(dev_out); |
986 | if (!fl.fld_dst) { | 987 | if (!fld.daddr) { |
987 | fl.fld_dst = | 988 | fld.daddr = |
988 | fl.fld_src = dnet_select_source(dev_out, 0, | 989 | fld.saddr = dnet_select_source(dev_out, 0, |
989 | RT_SCOPE_HOST); | 990 | RT_SCOPE_HOST); |
990 | if (!fl.fld_dst) | 991 | if (!fld.daddr) |
991 | goto out; | 992 | goto out; |
992 | } | 993 | } |
993 | fl.flowi_oif = init_net.loopback_dev->ifindex; | 994 | fld.flowidn_oif = init_net.loopback_dev->ifindex; |
994 | res.type = RTN_LOCAL; | 995 | res.type = RTN_LOCAL; |
995 | goto make_route; | 996 | goto make_route; |
996 | } | 997 | } |
@@ -999,8 +1000,8 @@ source_ok: | |||
999 | printk(KERN_DEBUG | 1000 | printk(KERN_DEBUG |
1000 | "dn_route_output_slow: initial checks complete." | 1001 | "dn_route_output_slow: initial checks complete." |
1001 | " dst=%o4x src=%04x oif=%d try_hard=%d\n", | 1002 | " dst=%o4x src=%04x oif=%d try_hard=%d\n", |
1002 | le16_to_cpu(fl.fld_dst), le16_to_cpu(fl.fld_src), | 1003 | le16_to_cpu(fld.daddr), le16_to_cpu(fld.saddr), |
1003 | fl.flowi_oif, try_hard); | 1004 | fld.flowidn_oif, try_hard); |
1004 | 1005 | ||
1005 | /* | 1006 | /* |
1006 | * N.B. If the kernel is compiled without router support then | 1007 | * N.B. If the kernel is compiled without router support then |
@@ -1008,7 +1009,7 @@ source_ok: | |||
1008 | * will always be executed. | 1009 | * will always be executed. |
1009 | */ | 1010 | */ |
1010 | err = -ESRCH; | 1011 | err = -ESRCH; |
1011 | if (try_hard || (err = dn_fib_lookup(&fl, &res)) != 0) { | 1012 | if (try_hard || (err = dn_fib_lookup(&fld, &res)) != 0) { |
1012 | struct dn_dev *dn_db; | 1013 | struct dn_dev *dn_db; |
1013 | if (err != -ESRCH) | 1014 | if (err != -ESRCH) |
1014 | goto out; | 1015 | goto out; |
@@ -1023,19 +1024,19 @@ source_ok: | |||
1023 | * here | 1024 | * here |
1024 | */ | 1025 | */ |
1025 | if (!try_hard) { | 1026 | if (!try_hard) { |
1026 | neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fl.fld_dst); | 1027 | neigh = neigh_lookup_nodev(&dn_neigh_table, &init_net, &fld.daddr); |
1027 | if (neigh) { | 1028 | if (neigh) { |
1028 | if ((oldflp->flowi_oif && | 1029 | if ((oldflp->flowidn_oif && |
1029 | (neigh->dev->ifindex != oldflp->flowi_oif)) || | 1030 | (neigh->dev->ifindex != oldflp->flowidn_oif)) || |
1030 | (oldflp->fld_src && | 1031 | (oldflp->saddr && |
1031 | (!dn_dev_islocal(neigh->dev, | 1032 | (!dn_dev_islocal(neigh->dev, |
1032 | oldflp->fld_src)))) { | 1033 | oldflp->saddr)))) { |
1033 | neigh_release(neigh); | 1034 | neigh_release(neigh); |
1034 | neigh = NULL; | 1035 | neigh = NULL; |
1035 | } else { | 1036 | } else { |
1036 | if (dev_out) | 1037 | if (dev_out) |
1037 | dev_put(dev_out); | 1038 | dev_put(dev_out); |
1038 | if (dn_dev_islocal(neigh->dev, fl.fld_dst)) { | 1039 | if (dn_dev_islocal(neigh->dev, fld.daddr)) { |
1039 | dev_out = init_net.loopback_dev; | 1040 | dev_out = init_net.loopback_dev; |
1040 | res.type = RTN_LOCAL; | 1041 | res.type = RTN_LOCAL; |
1041 | } else { | 1042 | } else { |
@@ -1055,7 +1056,7 @@ source_ok: | |||
1055 | goto out; | 1056 | goto out; |
1056 | dn_db = rcu_dereference_raw(dev_out->dn_ptr); | 1057 | dn_db = rcu_dereference_raw(dev_out->dn_ptr); |
1057 | /* Possible improvement - check all devices for local addr */ | 1058 | /* Possible improvement - check all devices for local addr */ |
1058 | if (dn_dev_islocal(dev_out, fl.fld_dst)) { | 1059 | if (dn_dev_islocal(dev_out, fld.daddr)) { |
1059 | dev_put(dev_out); | 1060 | dev_put(dev_out); |
1060 | dev_out = init_net.loopback_dev; | 1061 | dev_out = init_net.loopback_dev; |
1061 | dev_hold(dev_out); | 1062 | dev_hold(dev_out); |
@@ -1071,16 +1072,16 @@ select_source: | |||
1071 | if (neigh) | 1072 | if (neigh) |
1072 | gateway = ((struct dn_neigh *)neigh)->addr; | 1073 | gateway = ((struct dn_neigh *)neigh)->addr; |
1073 | if (gateway == 0) | 1074 | if (gateway == 0) |
1074 | gateway = fl.fld_dst; | 1075 | gateway = fld.daddr; |
1075 | if (fl.fld_src == 0) { | 1076 | if (fld.saddr == 0) { |
1076 | fl.fld_src = dnet_select_source(dev_out, gateway, | 1077 | fld.saddr = dnet_select_source(dev_out, gateway, |
1077 | res.type == RTN_LOCAL ? | 1078 | res.type == RTN_LOCAL ? |
1078 | RT_SCOPE_HOST : | 1079 | RT_SCOPE_HOST : |
1079 | RT_SCOPE_LINK); | 1080 | RT_SCOPE_LINK); |
1080 | if (fl.fld_src == 0 && res.type != RTN_LOCAL) | 1081 | if (fld.saddr == 0 && res.type != RTN_LOCAL) |
1081 | goto e_addr; | 1082 | goto e_addr; |
1082 | } | 1083 | } |
1083 | fl.flowi_oif = dev_out->ifindex; | 1084 | fld.flowidn_oif = dev_out->ifindex; |
1084 | goto make_route; | 1085 | goto make_route; |
1085 | } | 1086 | } |
1086 | free_res = 1; | 1087 | free_res = 1; |
@@ -1089,35 +1090,35 @@ select_source: | |||
1089 | goto e_inval; | 1090 | goto e_inval; |
1090 | 1091 | ||
1091 | if (res.type == RTN_LOCAL) { | 1092 | if (res.type == RTN_LOCAL) { |
1092 | if (!fl.fld_src) | 1093 | if (!fld.saddr) |
1093 | fl.fld_src = fl.fld_dst; | 1094 | fld.saddr = fld.daddr; |
1094 | if (dev_out) | 1095 | if (dev_out) |
1095 | dev_put(dev_out); | 1096 | dev_put(dev_out); |
1096 | dev_out = init_net.loopback_dev; | 1097 | dev_out = init_net.loopback_dev; |
1097 | dev_hold(dev_out); | 1098 | dev_hold(dev_out); |
1098 | fl.flowi_oif = dev_out->ifindex; | 1099 | fld.flowidn_oif = dev_out->ifindex; |
1099 | if (res.fi) | 1100 | if (res.fi) |
1100 | dn_fib_info_put(res.fi); | 1101 | dn_fib_info_put(res.fi); |
1101 | res.fi = NULL; | 1102 | res.fi = NULL; |
1102 | goto make_route; | 1103 | goto make_route; |
1103 | } | 1104 | } |
1104 | 1105 | ||
1105 | if (res.fi->fib_nhs > 1 && fl.flowi_oif == 0) | 1106 | if (res.fi->fib_nhs > 1 && fld.flowidn_oif == 0) |
1106 | dn_fib_select_multipath(&fl, &res); | 1107 | dn_fib_select_multipath(&fld, &res); |
1107 | 1108 | ||
1108 | /* | 1109 | /* |
1109 | * We could add some logic to deal with default routes here and | 1110 | * We could add some logic to deal with default routes here and |
1110 | * get rid of some of the special casing above. | 1111 | * get rid of some of the special casing above. |
1111 | */ | 1112 | */ |
1112 | 1113 | ||
1113 | if (!fl.fld_src) | 1114 | if (!fld.saddr) |
1114 | fl.fld_src = DN_FIB_RES_PREFSRC(res); | 1115 | fld.saddr = DN_FIB_RES_PREFSRC(res); |
1115 | 1116 | ||
1116 | if (dev_out) | 1117 | if (dev_out) |
1117 | dev_put(dev_out); | 1118 | dev_put(dev_out); |
1118 | dev_out = DN_FIB_RES_DEV(res); | 1119 | dev_out = DN_FIB_RES_DEV(res); |
1119 | dev_hold(dev_out); | 1120 | dev_hold(dev_out); |
1120 | fl.flowi_oif = dev_out->ifindex; | 1121 | fld.flowidn_oif = dev_out->ifindex; |
1121 | gateway = DN_FIB_RES_GW(res); | 1122 | gateway = DN_FIB_RES_GW(res); |
1122 | 1123 | ||
1123 | make_route: | 1124 | make_route: |
@@ -1131,19 +1132,19 @@ make_route: | |||
1131 | atomic_set(&rt->dst.__refcnt, 1); | 1132 | atomic_set(&rt->dst.__refcnt, 1); |
1132 | rt->dst.flags = DST_HOST; | 1133 | rt->dst.flags = DST_HOST; |
1133 | 1134 | ||
1134 | rt->fl.fld_src = oldflp->fld_src; | 1135 | rt->fld.saddr = oldflp->saddr; |
1135 | rt->fl.fld_dst = oldflp->fld_dst; | 1136 | rt->fld.daddr = oldflp->daddr; |
1136 | rt->fl.flowi_oif = oldflp->flowi_oif; | 1137 | rt->fld.flowidn_oif = oldflp->flowidn_oif; |
1137 | rt->fl.flowi_iif = 0; | 1138 | rt->fld.flowidn_iif = 0; |
1138 | rt->fl.flowi_mark = oldflp->flowi_mark; | 1139 | rt->fld.flowidn_mark = oldflp->flowidn_mark; |
1139 | 1140 | ||
1140 | rt->rt_saddr = fl.fld_src; | 1141 | rt->rt_saddr = fld.saddr; |
1141 | rt->rt_daddr = fl.fld_dst; | 1142 | rt->rt_daddr = fld.daddr; |
1142 | rt->rt_gateway = gateway ? gateway : fl.fld_dst; | 1143 | rt->rt_gateway = gateway ? gateway : fld.daddr; |
1143 | rt->rt_local_src = fl.fld_src; | 1144 | rt->rt_local_src = fld.saddr; |
1144 | 1145 | ||
1145 | rt->rt_dst_map = fl.fld_dst; | 1146 | rt->rt_dst_map = fld.daddr; |
1146 | rt->rt_src_map = fl.fld_src; | 1147 | rt->rt_src_map = fld.saddr; |
1147 | 1148 | ||
1148 | rt->dst.dev = dev_out; | 1149 | rt->dst.dev = dev_out; |
1149 | dev_hold(dev_out); | 1150 | dev_hold(dev_out); |
@@ -1161,7 +1162,7 @@ make_route: | |||
1161 | if (err) | 1162 | if (err) |
1162 | goto e_neighbour; | 1163 | goto e_neighbour; |
1163 | 1164 | ||
1164 | hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst); | 1165 | hash = dn_hash(rt->fld.saddr, rt->fld.daddr); |
1165 | dn_insert_route(rt, hash, (struct dn_route **)pprt); | 1166 | dn_insert_route(rt, hash, (struct dn_route **)pprt); |
1166 | 1167 | ||
1167 | done: | 1168 | done: |
@@ -1192,20 +1193,20 @@ e_neighbour: | |||
1192 | /* | 1193 | /* |
1193 | * N.B. The flags may be moved into the flowi at some future stage. | 1194 | * N.B. The flags may be moved into the flowi at some future stage. |
1194 | */ | 1195 | */ |
1195 | static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *flp, int flags) | 1196 | static int __dn_route_output_key(struct dst_entry **pprt, const struct flowidn *flp, int flags) |
1196 | { | 1197 | { |
1197 | unsigned hash = dn_hash(flp->fld_src, flp->fld_dst); | 1198 | unsigned hash = dn_hash(flp->saddr, flp->daddr); |
1198 | struct dn_route *rt = NULL; | 1199 | struct dn_route *rt = NULL; |
1199 | 1200 | ||
1200 | if (!(flags & MSG_TRYHARD)) { | 1201 | if (!(flags & MSG_TRYHARD)) { |
1201 | rcu_read_lock_bh(); | 1202 | rcu_read_lock_bh(); |
1202 | for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt; | 1203 | for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt; |
1203 | rt = rcu_dereference_bh(rt->dst.dn_next)) { | 1204 | rt = rcu_dereference_bh(rt->dst.dn_next)) { |
1204 | if ((flp->fld_dst == rt->fl.fld_dst) && | 1205 | if ((flp->daddr == rt->fld.daddr) && |
1205 | (flp->fld_src == rt->fl.fld_src) && | 1206 | (flp->saddr == rt->fld.saddr) && |
1206 | (flp->flowi_mark == rt->fl.flowi_mark) && | 1207 | (flp->flowidn_mark == rt->fld.flowidn_mark) && |
1207 | dn_is_output_route(rt) && | 1208 | dn_is_output_route(rt) && |
1208 | (rt->fl.flowi_oif == flp->flowi_oif)) { | 1209 | (rt->fld.flowidn_oif == flp->flowidn_oif)) { |
1209 | dst_use(&rt->dst, jiffies); | 1210 | dst_use(&rt->dst, jiffies); |
1210 | rcu_read_unlock_bh(); | 1211 | rcu_read_unlock_bh(); |
1211 | *pprt = &rt->dst; | 1212 | *pprt = &rt->dst; |
@@ -1218,13 +1219,14 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl | |||
1218 | return dn_route_output_slow(pprt, flp, flags); | 1219 | return dn_route_output_slow(pprt, flp, flags); |
1219 | } | 1220 | } |
1220 | 1221 | ||
1221 | static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int flags) | 1222 | static int dn_route_output_key(struct dst_entry **pprt, struct flowidn *flp, int flags) |
1222 | { | 1223 | { |
1223 | int err; | 1224 | int err; |
1224 | 1225 | ||
1225 | err = __dn_route_output_key(pprt, flp, flags); | 1226 | err = __dn_route_output_key(pprt, flp, flags); |
1226 | if (err == 0 && flp->flowi_proto) { | 1227 | if (err == 0 && flp->flowidn_proto) { |
1227 | *pprt = xfrm_lookup(&init_net, *pprt, flp, NULL, 0); | 1228 | *pprt = xfrm_lookup(&init_net, *pprt, |
1229 | flowidn_to_flowi(flp), NULL, 0); | ||
1228 | if (IS_ERR(*pprt)) { | 1230 | if (IS_ERR(*pprt)) { |
1229 | err = PTR_ERR(*pprt); | 1231 | err = PTR_ERR(*pprt); |
1230 | *pprt = NULL; | 1232 | *pprt = NULL; |
@@ -1233,15 +1235,16 @@ static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int f | |||
1233 | return err; | 1235 | return err; |
1234 | } | 1236 | } |
1235 | 1237 | ||
1236 | int dn_route_output_sock(struct dst_entry **pprt, struct flowi *fl, struct sock *sk, int flags) | 1238 | int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *fl, struct sock *sk, int flags) |
1237 | { | 1239 | { |
1238 | int err; | 1240 | int err; |
1239 | 1241 | ||
1240 | err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD); | 1242 | err = __dn_route_output_key(pprt, fl, flags & MSG_TRYHARD); |
1241 | if (err == 0 && fl->flowi_proto) { | 1243 | if (err == 0 && fl->flowidn_proto) { |
1242 | if (!(flags & MSG_DONTWAIT)) | 1244 | if (!(flags & MSG_DONTWAIT)) |
1243 | fl->flowi_flags |= FLOWI_FLAG_CAN_SLEEP; | 1245 | fl->flowidn_flags |= FLOWI_FLAG_CAN_SLEEP; |
1244 | *pprt = xfrm_lookup(&init_net, *pprt, fl, sk, 0); | 1246 | *pprt = xfrm_lookup(&init_net, *pprt, |
1247 | flowidn_to_flowi(fl), sk, 0); | ||
1245 | if (IS_ERR(*pprt)) { | 1248 | if (IS_ERR(*pprt)) { |
1246 | err = PTR_ERR(*pprt); | 1249 | err = PTR_ERR(*pprt); |
1247 | *pprt = NULL; | 1250 | *pprt = NULL; |
@@ -1262,12 +1265,12 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1262 | int flags = 0; | 1265 | int flags = 0; |
1263 | __le16 gateway = 0; | 1266 | __le16 gateway = 0; |
1264 | __le16 local_src = 0; | 1267 | __le16 local_src = 0; |
1265 | struct flowi fl = { | 1268 | struct flowidn fld = { |
1266 | .fld_dst = cb->dst, | 1269 | .daddr = cb->dst, |
1267 | .fld_src = cb->src, | 1270 | .saddr = cb->src, |
1268 | .fld_scope = RT_SCOPE_UNIVERSE, | 1271 | .flowidn_scope = RT_SCOPE_UNIVERSE, |
1269 | .flowi_mark = skb->mark, | 1272 | .flowidn_mark = skb->mark, |
1270 | .flowi_iif = skb->dev->ifindex, | 1273 | .flowidn_iif = skb->dev->ifindex, |
1271 | }; | 1274 | }; |
1272 | struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE }; | 1275 | struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE }; |
1273 | int err = -EINVAL; | 1276 | int err = -EINVAL; |
@@ -1279,7 +1282,7 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1279 | goto out; | 1282 | goto out; |
1280 | 1283 | ||
1281 | /* Zero source addresses are not allowed */ | 1284 | /* Zero source addresses are not allowed */ |
1282 | if (fl.fld_src == 0) | 1285 | if (fld.saddr == 0) |
1283 | goto out; | 1286 | goto out; |
1284 | 1287 | ||
1285 | /* | 1288 | /* |
@@ -1293,7 +1296,7 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1293 | if (dn_dev_islocal(in_dev, cb->src)) | 1296 | if (dn_dev_islocal(in_dev, cb->src)) |
1294 | goto out; | 1297 | goto out; |
1295 | 1298 | ||
1296 | err = dn_fib_lookup(&fl, &res); | 1299 | err = dn_fib_lookup(&fld, &res); |
1297 | if (err) { | 1300 | if (err) { |
1298 | if (err != -ESRCH) | 1301 | if (err != -ESRCH) |
1299 | goto out; | 1302 | goto out; |
@@ -1305,7 +1308,7 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1305 | 1308 | ||
1306 | res.type = RTN_LOCAL; | 1309 | res.type = RTN_LOCAL; |
1307 | } else { | 1310 | } else { |
1308 | __le16 src_map = fl.fld_src; | 1311 | __le16 src_map = fld.saddr; |
1309 | free_res = 1; | 1312 | free_res = 1; |
1310 | 1313 | ||
1311 | out_dev = DN_FIB_RES_DEV(res); | 1314 | out_dev = DN_FIB_RES_DEV(res); |
@@ -1318,22 +1321,22 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1318 | dev_hold(out_dev); | 1321 | dev_hold(out_dev); |
1319 | 1322 | ||
1320 | if (res.r) | 1323 | if (res.r) |
1321 | src_map = fl.fld_src; /* no NAT support for now */ | 1324 | src_map = fld.saddr; /* no NAT support for now */ |
1322 | 1325 | ||
1323 | gateway = DN_FIB_RES_GW(res); | 1326 | gateway = DN_FIB_RES_GW(res); |
1324 | if (res.type == RTN_NAT) { | 1327 | if (res.type == RTN_NAT) { |
1325 | fl.fld_dst = dn_fib_rules_map_destination(fl.fld_dst, &res); | 1328 | fld.daddr = dn_fib_rules_map_destination(fld.daddr, &res); |
1326 | dn_fib_res_put(&res); | 1329 | dn_fib_res_put(&res); |
1327 | free_res = 0; | 1330 | free_res = 0; |
1328 | if (dn_fib_lookup(&fl, &res)) | 1331 | if (dn_fib_lookup(&fld, &res)) |
1329 | goto e_inval; | 1332 | goto e_inval; |
1330 | free_res = 1; | 1333 | free_res = 1; |
1331 | if (res.type != RTN_UNICAST) | 1334 | if (res.type != RTN_UNICAST) |
1332 | goto e_inval; | 1335 | goto e_inval; |
1333 | flags |= RTCF_DNAT; | 1336 | flags |= RTCF_DNAT; |
1334 | gateway = fl.fld_dst; | 1337 | gateway = fld.daddr; |
1335 | } | 1338 | } |
1336 | fl.fld_src = src_map; | 1339 | fld.saddr = src_map; |
1337 | } | 1340 | } |
1338 | 1341 | ||
1339 | switch(res.type) { | 1342 | switch(res.type) { |
@@ -1347,8 +1350,8 @@ static int dn_route_input_slow(struct sk_buff *skb) | |||
1347 | if (dn_db->parms.forwarding == 0) | 1350 | if (dn_db->parms.forwarding == 0) |
1348 | goto e_inval; | 1351 | goto e_inval; |
1349 | 1352 | ||
1350 | if (res.fi->fib_nhs > 1 && fl.flowi_oif == 0) | 1353 | if (res.fi->fib_nhs > 1 && fld.flowidn_oif == 0) |
1351 | dn_fib_select_multipath(&fl, &res); | 1354 | dn_fib_select_multipath(&fld, &res); |
1352 | 1355 | ||
1353 | /* | 1356 | /* |
1354 | * Check for out_dev == in_dev. We use the RTCF_DOREDIRECT | 1357 | * 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) | |||
1366 | break; | 1369 | break; |
1367 | case RTN_LOCAL: | 1370 | case RTN_LOCAL: |
1368 | flags |= RTCF_LOCAL; | 1371 | flags |= RTCF_LOCAL; |
1369 | fl.fld_src = cb->dst; | 1372 | fld.saddr = cb->dst; |
1370 | fl.fld_dst = cb->src; | 1373 | fld.daddr = cb->src; |
1371 | 1374 | ||
1372 | /* Routing tables gave us a gateway */ | 1375 | /* Routing tables gave us a gateway */ |
1373 | if (gateway) | 1376 | if (gateway) |
@@ -1400,21 +1403,21 @@ make_route: | |||
1400 | if (rt == NULL) | 1403 | if (rt == NULL) |
1401 | goto e_nobufs; | 1404 | goto e_nobufs; |
1402 | 1405 | ||
1403 | rt->rt_saddr = fl.fld_src; | 1406 | rt->rt_saddr = fld.saddr; |
1404 | rt->rt_daddr = fl.fld_dst; | 1407 | rt->rt_daddr = fld.daddr; |
1405 | rt->rt_gateway = fl.fld_dst; | 1408 | rt->rt_gateway = fld.daddr; |
1406 | if (gateway) | 1409 | if (gateway) |
1407 | rt->rt_gateway = gateway; | 1410 | rt->rt_gateway = gateway; |
1408 | rt->rt_local_src = local_src ? local_src : rt->rt_saddr; | 1411 | rt->rt_local_src = local_src ? local_src : rt->rt_saddr; |
1409 | 1412 | ||
1410 | rt->rt_dst_map = fl.fld_dst; | 1413 | rt->rt_dst_map = fld.daddr; |
1411 | rt->rt_src_map = fl.fld_src; | 1414 | rt->rt_src_map = fld.saddr; |
1412 | 1415 | ||
1413 | rt->fl.fld_src = cb->src; | 1416 | rt->fld.saddr = cb->src; |
1414 | rt->fl.fld_dst = cb->dst; | 1417 | rt->fld.daddr = cb->dst; |
1415 | rt->fl.flowi_oif = 0; | 1418 | rt->fld.flowidn_oif = 0; |
1416 | rt->fl.flowi_iif = in_dev->ifindex; | 1419 | rt->fld.flowidn_iif = in_dev->ifindex; |
1417 | rt->fl.flowi_mark = fl.flowi_mark; | 1420 | rt->fld.flowidn_mark = fld.flowidn_mark; |
1418 | 1421 | ||
1419 | rt->dst.flags = DST_HOST; | 1422 | rt->dst.flags = DST_HOST; |
1420 | rt->dst.neighbour = neigh; | 1423 | rt->dst.neighbour = neigh; |
@@ -1444,7 +1447,7 @@ make_route: | |||
1444 | if (err) | 1447 | if (err) |
1445 | goto e_neighbour; | 1448 | goto e_neighbour; |
1446 | 1449 | ||
1447 | hash = dn_hash(rt->fl.fld_src, rt->fl.fld_dst); | 1450 | hash = dn_hash(rt->fld.saddr, rt->fld.daddr); |
1448 | dn_insert_route(rt, hash, &rt); | 1451 | dn_insert_route(rt, hash, &rt); |
1449 | skb_dst_set(skb, &rt->dst); | 1452 | skb_dst_set(skb, &rt->dst); |
1450 | 1453 | ||
@@ -1484,11 +1487,11 @@ static int dn_route_input(struct sk_buff *skb) | |||
1484 | rcu_read_lock(); | 1487 | rcu_read_lock(); |
1485 | for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL; | 1488 | for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL; |
1486 | rt = rcu_dereference(rt->dst.dn_next)) { | 1489 | rt = rcu_dereference(rt->dst.dn_next)) { |
1487 | if ((rt->fl.fld_src == cb->src) && | 1490 | if ((rt->fld.saddr == cb->src) && |
1488 | (rt->fl.fld_dst == cb->dst) && | 1491 | (rt->fld.daddr == cb->dst) && |
1489 | (rt->fl.flowi_oif == 0) && | 1492 | (rt->fld.flowidn_oif == 0) && |
1490 | (rt->fl.flowi_mark == skb->mark) && | 1493 | (rt->fld.flowidn_mark == skb->mark) && |
1491 | (rt->fl.flowi_iif == cb->iif)) { | 1494 | (rt->fld.flowidn_iif == cb->iif)) { |
1492 | dst_use(&rt->dst, jiffies); | 1495 | dst_use(&rt->dst, jiffies); |
1493 | rcu_read_unlock(); | 1496 | rcu_read_unlock(); |
1494 | skb_dst_set(skb, (struct dst_entry *)rt); | 1497 | 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, | |||
1524 | if (rt->rt_flags & RTCF_NOTIFY) | 1527 | if (rt->rt_flags & RTCF_NOTIFY) |
1525 | r->rtm_flags |= RTM_F_NOTIFY; | 1528 | r->rtm_flags |= RTM_F_NOTIFY; |
1526 | RTA_PUT(skb, RTA_DST, 2, &rt->rt_daddr); | 1529 | RTA_PUT(skb, RTA_DST, 2, &rt->rt_daddr); |
1527 | if (rt->fl.fld_src) { | 1530 | if (rt->fld.saddr) { |
1528 | r->rtm_src_len = 16; | 1531 | r->rtm_src_len = 16; |
1529 | RTA_PUT(skb, RTA_SRC, 2, &rt->fl.fld_src); | 1532 | RTA_PUT(skb, RTA_SRC, 2, &rt->fld.saddr); |
1530 | } | 1533 | } |
1531 | if (rt->dst.dev) | 1534 | if (rt->dst.dev) |
1532 | RTA_PUT(skb, RTA_OIF, sizeof(int), &rt->dst.dev->ifindex); | 1535 | 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, | |||
1545 | rt->dst.error) < 0) | 1548 | rt->dst.error) < 0) |
1546 | goto rtattr_failure; | 1549 | goto rtattr_failure; |
1547 | if (dn_is_input_route(rt)) | 1550 | if (dn_is_input_route(rt)) |
1548 | RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.flowi_iif); | 1551 | RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fld.flowidn_iif); |
1549 | 1552 | ||
1550 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 1553 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1551 | return skb->len; | 1554 | return skb->len; |
@@ -1568,13 +1571,13 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void | |||
1568 | struct dn_skb_cb *cb; | 1571 | struct dn_skb_cb *cb; |
1569 | int err; | 1572 | int err; |
1570 | struct sk_buff *skb; | 1573 | struct sk_buff *skb; |
1571 | struct flowi fl; | 1574 | struct flowidn fld; |
1572 | 1575 | ||
1573 | if (!net_eq(net, &init_net)) | 1576 | if (!net_eq(net, &init_net)) |
1574 | return -EINVAL; | 1577 | return -EINVAL; |
1575 | 1578 | ||
1576 | memset(&fl, 0, sizeof(fl)); | 1579 | memset(&fld, 0, sizeof(fld)); |
1577 | fl.flowi_proto = DNPROTO_NSP; | 1580 | fld.flowidn_proto = DNPROTO_NSP; |
1578 | 1581 | ||
1579 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); | 1582 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); |
1580 | if (skb == NULL) | 1583 | if (skb == NULL) |
@@ -1583,15 +1586,15 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void | |||
1583 | cb = DN_SKB_CB(skb); | 1586 | cb = DN_SKB_CB(skb); |
1584 | 1587 | ||
1585 | if (rta[RTA_SRC-1]) | 1588 | if (rta[RTA_SRC-1]) |
1586 | memcpy(&fl.fld_src, RTA_DATA(rta[RTA_SRC-1]), 2); | 1589 | memcpy(&fld.saddr, RTA_DATA(rta[RTA_SRC-1]), 2); |
1587 | if (rta[RTA_DST-1]) | 1590 | if (rta[RTA_DST-1]) |
1588 | memcpy(&fl.fld_dst, RTA_DATA(rta[RTA_DST-1]), 2); | 1591 | memcpy(&fld.daddr, RTA_DATA(rta[RTA_DST-1]), 2); |
1589 | if (rta[RTA_IIF-1]) | 1592 | if (rta[RTA_IIF-1]) |
1590 | memcpy(&fl.flowi_iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int)); | 1593 | memcpy(&fld.flowidn_iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int)); |
1591 | 1594 | ||
1592 | if (fl.flowi_iif) { | 1595 | if (fld.flowidn_iif) { |
1593 | struct net_device *dev; | 1596 | struct net_device *dev; |
1594 | if ((dev = dev_get_by_index(&init_net, fl.flowi_iif)) == NULL) { | 1597 | if ((dev = dev_get_by_index(&init_net, fld.flowidn_iif)) == NULL) { |
1595 | kfree_skb(skb); | 1598 | kfree_skb(skb); |
1596 | return -ENODEV; | 1599 | return -ENODEV; |
1597 | } | 1600 | } |
@@ -1602,8 +1605,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void | |||
1602 | } | 1605 | } |
1603 | skb->protocol = htons(ETH_P_DNA_RT); | 1606 | skb->protocol = htons(ETH_P_DNA_RT); |
1604 | skb->dev = dev; | 1607 | skb->dev = dev; |
1605 | cb->src = fl.fld_src; | 1608 | cb->src = fld.saddr; |
1606 | cb->dst = fl.fld_dst; | 1609 | cb->dst = fld.daddr; |
1607 | local_bh_disable(); | 1610 | local_bh_disable(); |
1608 | err = dn_route_input(skb); | 1611 | err = dn_route_input(skb); |
1609 | local_bh_enable(); | 1612 | local_bh_enable(); |
@@ -1615,8 +1618,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void | |||
1615 | int oif = 0; | 1618 | int oif = 0; |
1616 | if (rta[RTA_OIF - 1]) | 1619 | if (rta[RTA_OIF - 1]) |
1617 | memcpy(&oif, RTA_DATA(rta[RTA_OIF - 1]), sizeof(int)); | 1620 | memcpy(&oif, RTA_DATA(rta[RTA_OIF - 1]), sizeof(int)); |
1618 | fl.flowi_oif = oif; | 1621 | fld.flowidn_oif = oif; |
1619 | err = dn_route_output_key((struct dst_entry **)&rt, &fl, 0); | 1622 | err = dn_route_output_key((struct dst_entry **)&rt, &fld, 0); |
1620 | } | 1623 | } |
1621 | 1624 | ||
1622 | if (skb->dev) | 1625 | if (skb->dev) |