Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
bef55aeb
Commit
bef55aeb
authored
Mar 12, 2011
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decnet: Convert to use flowidn where applicable.
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parent
1958b856
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
196 additions
and
185 deletions
+196
-185
include/net/dn.h
include/net/dn.h
+3
-3
include/net/dn_fib.h
include/net/dn_fib.h
+4
-4
include/net/dn_route.h
include/net/dn_route.h
+4
-4
include/net/flow.h
include/net/flow.h
+8
-4
net/decnet/af_decnet.c
net/decnet/af_decnet.c
+8
-8
net/decnet/dn_fib.c
net/decnet/dn_fib.c
+12
-11
net/decnet/dn_nsp_out.c
net/decnet/dn_nsp_out.c
+8
-8
net/decnet/dn_route.c
net/decnet/dn_route.c
+136
-133
net/decnet/dn_rules.c
net/decnet/dn_rules.c
+10
-7
net/decnet/dn_table.c
net/decnet/dn_table.c
+3
-3
No files found.
include/net/dn.h
View file @
bef55aeb
...
...
@@ -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
flowi
dn
*
fld
,
struct
dn_scp
*
scp
)
{
fl
->
u
.
dn
.
uli
.
ports
.
sport
=
scp
->
addrloc
;
fl
->
u
.
dn
.
uli
.
ports
.
dport
=
scp
->
addrrem
;
fl
d
->
fld_
sport
=
scp
->
addrloc
;
fl
d
->
fld_
dport
=
scp
->
addrrem
;
}
extern
unsigned
dn_mss_from_pmtu
(
struct
net_device
*
dev
,
int
mtu
);
...
...
include/net/dn_fib.h
View file @
bef55aeb
...
...
@@ -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
flowi
dn
*
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
);
...
...
@@ -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
flowi
dn
*
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
flowi
dn
*
fld
,
struct
dn_fib_res
*
res
);
/*
...
...
@@ -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
flowi
dn
*
fld
,
struct
dn_fib_res
*
res
);
extern
int
dn_fib_dump
(
struct
sk_buff
*
skb
,
struct
netlink_callback
*
cb
);
...
...
include/net/dn_route.h
View file @
bef55aeb
...
...
@@ -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
flowi
dn
*
,
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
);
...
...
@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay);
struct
dn_route
{
struct
dst_entry
dst
;
struct
flowi
fl
;
struct
flowi
dn
fld
;
__le16
rt_saddr
;
__le16
rt_daddr
;
...
...
@@ -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
->
fl
d
.
flowidn
_iif
!=
0
;
}
static
inline
bool
dn_is_output_route
(
struct
dn_route
*
rt
)
{
return
rt
->
fl
.
flowi
_iif
==
0
;
return
rt
->
fl
d
.
flowidn
_iif
==
0
;
}
extern
void
dn_route_init
(
void
);
...
...
include/net/flow.h
View file @
bef55aeb
...
...
@@ -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
{
...
...
@@ -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
)
...
...
net/decnet/af_decnet.c
View file @
bef55aeb
...
...
@@ -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
flowi
dn
fld
;
if
(
sock
->
state
==
SS_CONNECTED
)
goto
out
;
...
...
@@ -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
(
&
fl
d
,
0
,
sizeof
(
fld
));
fl
d
.
flowidn
_oif
=
sk
->
sk_bound_dev_if
;
fl
d
.
daddr
=
dn_saddr2dn
(
&
scp
->
peer
);
fl
d
.
saddr
=
dn_saddr2dn
(
&
scp
->
addr
);
dn_sk_ports_copy
(
&
fl
d
,
scp
);
fl
d
.
flowidn
_proto
=
DNPROTO_NSP
;
if
(
dn_route_output_sock
(
&
sk
->
sk_dst_cache
,
&
fl
d
,
sk
,
flags
)
<
0
)
goto
out
;
sk
->
sk_route_caps
=
sk
->
sk_dst_cache
->
dev
->
features
;
sock
->
state
=
SS_CONNECTING
;
...
...
net/decnet/dn_fib.c
View file @
bef55aeb
...
...
@@ -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
flowi
dn
fld
;
struct
dn_fib_res
res
;
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
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
(
&
fl
d
,
0
,
sizeof
(
fld
));
fl
d
.
daddr
=
nh
->
nh_gw
;
fl
d
.
flowidn
_oif
=
nh
->
nh_oif
;
fl
d
.
flowidn
_scope
=
r
->
rtm_scope
+
1
;
if
(
fl
.
fld
_scope
<
RT_SCOPE_LINK
)
fl
.
fld
_scope
=
RT_SCOPE_LINK
;
if
(
fl
d
.
flowidn
_scope
<
RT_SCOPE_LINK
)
fl
d
.
flowidn
_scope
=
RT_SCOPE_LINK
;
if
((
err
=
dn_fib_lookup
(
&
fl
,
&
res
))
!=
0
)
if
((
err
=
dn_fib_lookup
(
&
fl
d
,
&
res
))
!=
0
)
return
err
;
err
=
-
EINVAL
;
...
...
@@ -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
flowi
dn
*
fld
,
struct
dn_fib_res
*
res
)
{
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 *
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
)
{
...
...
@@ -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
flowi
dn
*
fld
,
struct
dn_fib_res
*
res
)
{
struct
dn_fib_info
*
fi
=
res
->
fi
;
int
w
;
...
...
net/decnet/dn_nsp_out.c
View file @
bef55aeb
...
...
@@ -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
flowi
dn
fld
;
skb_reset_transport_header
(
skb
);
scp
->
stamp
=
jiffies
;
...
...
@@ -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
(
&
fl
d
,
0
,
sizeof
(
fld
));
fl
d
.
flowidn
_oif
=
sk
->
sk_bound_dev_if
;
fl
d
.
saddr
=
dn_saddr2dn
(
&
scp
->
addr
);
fl
d
.
daddr
=
dn_saddr2dn
(
&
scp
->
peer
);
dn_sk_ports_copy
(
&
fl
d
,
scp
);
fl
d
.
flowidn
_proto
=
DNPROTO_NSP
;
if
(
dn_route_output_sock
(
&
sk
->
sk_dst_cache
,
&
fl
d
,
sk
,
0
)
==
0
)
{
dst
=
sk_dst_get
(
sk
);
sk
->
sk_route_caps
=
dst
->
dev
->
features
;
goto
try_again
;
...
...
net/decnet/dn_route.c
View file @
bef55aeb
...
...
@@ -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
flowi
dn
*
fl1
,
struct
flowidn
*
fl2
)
{
return
((
fl1
->
fld_dst
^
fl2
->
fld_dst
)
|
(
fl1
->
fld_src
^
fl2
->
fld_src
)
|
(
fl1
->
flowi
_mark
^
fl2
->
flowi
_mark
)
|
(
fl1
->
fl
d_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
->
flowi
dn_mark
^
fl2
->
flowidn
_mark
)
|
(
fl1
->
fl
owidn_scope
^
fl2
->
flowidn
_scope
)
|
(
fl1
->
flowi
dn_oif
^
fl2
->
flowidn
_oif
)
|
(
fl1
->
flowi
dn_iif
^
fl2
->
flowidn
_iif
))
==
0
;
}
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
);
while
((
rth
=
rcu_dereference_protected
(
*
rthp
,
lockdep_is_held
(
&
dn_rt_hash_table
[
hash
].
lock
)))
!=
NULL
)
{
if
(
compare_keys
(
&
rth
->
fl
,
&
rt
->
fl
))
{
if
(
compare_keys
(
&
rth
->
fl
d
,
&
rt
->
fld
))
{
/* Put it first */
*
rthp
=
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
;
}
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
flowi
dn
*
oldflp
,
int
try_hard
)
{
struct
flowi
fl
=
{
.
fld_dst
=
oldflp
->
fld_dst
,
.
fld_src
=
oldflp
->
fld_src
,
.
fl
d
_scope
=
RT_SCOPE_UNIVERSE
,
.
flowi
_mark
=
oldflp
->
flowi
_mark
,
.
flowi_iif
=
init_net
.
loopback_dev
->
ifindex
,
.
flowi
_oif
=
oldflp
->
flowi
_oif
,
struct
flowi
dn
fld
=
{
.
daddr
=
oldflp
->
daddr
,
.
saddr
=
oldflp
->
saddr
,
.
fl
owidn
_scope
=
RT_SCOPE_UNIVERSE
,
.
flowi
dn_mark
=
oldflp
->
flowidn
_mark
,
.
flowi
dn
_iif
=
init_net
.
loopback_dev
->
ifindex
,
.
flowi
dn_oif
=
oldflp
->
flowidn
_oif
,
};
struct
dn_route
*
rt
=
NULL
;
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
)
printk
(
KERN_DEBUG
"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
(
oldflp
->
flowi_oif
)
{
dev_out
=
dev_get_by_index
(
&
init_net
,
oldflp
->
flowi_oif
);
if
(
oldflp
->
flowi
dn
_oif
)
{
dev_out
=
dev_get_by_index
(
&
init_net
,
oldflp
->
flowi
dn
_oif
);
err
=
-
ENODEV
;
if
(
dev_out
&&
dev_out
->
dn_ptr
==
NULL
)
{
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
(
oldflp
->
fld_src
)
{
if
(
oldflp
->
saddr
)
{
err
=
-
EADDRNOTAVAIL
;
if
(
dev_out
)
{
if
(
dn_dev_islocal
(
dev_out
,
oldflp
->
fld_src
))
if
(
dn_dev_islocal
(
dev_out
,
oldflp
->
saddr
))
goto
source_ok
;
dev_put
(
dev_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
)
{
if
(
!
dev
->
dn_ptr
)
continue
;
if
(
!
dn_dev_islocal
(
dev
,
oldflp
->
fld_src
))
if
(
!
dn_dev_islocal
(
dev
,
oldflp
->
saddr
))
continue
;
if
((
dev
->
flags
&
IFF_LOOPBACK
)
&&
oldflp
->
fld_dst
&&
!
dn_dev_islocal
(
dev
,
oldflp
->
fld_dst
))
oldflp
->
daddr
&&
!
dn_dev_islocal
(
dev
,
oldflp
->
daddr
))
continue
;
dev_out
=
dev
;
...
...
@@ -975,22 +976,22 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
}
/* No destination? Assume its local */
if
(
!
fl
.
fld_dst
)
{
fl
.
fld_dst
=
fl
.
fld_src
;
if
(
!
fl
d
.
daddr
)
{
fl
d
.
daddr
=
fld
.
saddr
;
err
=
-
EADDRNOTAVAIL
;
if
(
dev_out
)
dev_put
(
dev_out
);
dev_out
=
init_net
.
loopback_dev
;
dev_hold
(
dev_out
);
if
(
!
fl
.
fld_dst
)
{
fl
.
fld_dst
=
fl
.
fld_src
=
dnet_select_source
(
dev_out
,
0
,
if
(
!
fl
d
.
daddr
)
{
fl
d
.
daddr
=
fl
d
.
saddr
=
dnet_select_source
(
dev_out
,
0
,
RT_SCOPE_HOST
);
if
(
!
fl
.
fld_dst
)
if
(
!
fl
d
.
daddr
)
goto
out
;
}
fl
.
flowi
_oif
=
init_net
.
loopback_dev
->
ifindex
;
fl
d
.
flowidn
_oif
=
init_net
.
loopback_dev
->
ifindex
;
res
.
type
=
RTN_LOCAL
;
goto
make_route
;
}
...
...
@@ -999,8 +1000,8 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
printk
(
KERN_DEBUG
"dn_route_output_slow: initial checks complete."
" 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
(
fl
d
.
daddr
),
le16_to_cpu
(
fld
.
saddr
),
fl
d
.
flowidn
_oif
,
try_hard
);
/*
* N.B. If the kernel is compiled without router support then
...
...
@@ -1008,7 +1009,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
* will always be executed.
*/
err
=
-
ESRCH
;
if
(
try_hard
||
(
err
=
dn_fib_lookup
(
&
fl
,
&
res
))
!=
0
)
{
if
(
try_hard
||
(
err
=
dn_fib_lookup
(
&
fl
d
,
&
res
))
!=
0
)
{
struct
dn_dev
*
dn_db
;
if
(
err
!=
-
ESRCH
)
goto
out
;
...
...
@@ -1023,19 +1024,19 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
* here
*/
if
(
!
try_hard
)
{
neigh
=
neigh_lookup_nodev
(
&
dn_neigh_table
,
&
init_net
,
&
fl
.
fld_dst
);
neigh
=
neigh_lookup_nodev
(
&
dn_neigh_table
,
&
init_net
,
&
fl
d
.
daddr
);
if
(
neigh
)
{
if
((
oldflp
->
flowi_oif
&&
(
neigh
->
dev
->
ifindex
!=
oldflp
->
flowi_oif
))
||
(
oldflp
->
fld_src
&&
if
((
oldflp
->
flowi
dn
_oif
&&
(
neigh
->
dev
->
ifindex
!=
oldflp
->
flowi
dn
_oif
))
||
(
oldflp
->
saddr
&&
(
!
dn_dev_islocal
(
neigh
->
dev
,
oldflp
->
fld_src
))))
{
oldflp
->
saddr
))))
{
neigh_release
(
neigh
);
neigh
=
NULL
;
}
else
{
if
(
dev_out
)
dev_put
(
dev_out
);
if
(
dn_dev_islocal
(
neigh
->
dev
,
fl
.
fld_dst
))
{
if
(
dn_dev_islocal
(
neigh
->
dev
,
fl
d
.
daddr
))
{
dev_out
=
init_net
.
loopback_dev
;
res
.
type
=
RTN_LOCAL
;
}
else
{
...
...
@@ -1055,7 +1056,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
goto
out
;
dn_db
=
rcu_dereference_raw
(
dev_out
->
dn_ptr
);
/* Possible improvement - check all devices for local addr */
if
(
dn_dev_islocal
(
dev_out
,
fl
.
fld_dst
))
{
if
(
dn_dev_islocal
(
dev_out
,
fl
d
.
daddr
))
{
dev_put
(
dev_out
);
dev_out
=
init_net
.
loopback_dev
;
dev_hold
(
dev_out
);
...
...
@@ -1071,16 +1072,16 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
if
(
neigh
)
gateway
=
((
struct
dn_neigh
*
)
neigh
)
->
addr
;
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
=
fl
d
.
daddr
;
if
(
fl
d
.
saddr
==
0
)
{
fl
d
.
saddr
=
dnet_select_source
(
dev_out
,
gateway
,
res
.
type
==
RTN_LOCAL
?
RT_SCOPE_HOST
:
RT_SCOPE_LINK
);
if
(
fl
d
.
saddr
==
0
&&
res
.
type
!=
RTN_LOCAL
)
goto
e_addr
;
}
fl
.
flowi
_oif
=
dev_out
->
ifindex
;
fl
d
.
flowidn
_oif
=
dev_out
->
ifindex
;
goto
make_route
;
}
free_res
=
1
;
...
...
@@ -1089,35 +1090,35 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
goto
e_inval
;
if
(
res
.
type
==
RTN_LOCAL
)
{
if
(
!
fl
.
fld_src
)
fl
.
fld_src
=
fl
.
fld_dst
;
if
(
!
fl
d
.
saddr
)
fl
d
.
saddr
=
fld
.
daddr
;
if
(
dev_out
)
dev_put
(
dev_out
);
dev_out
=
init_net
.
loopback_dev
;
dev_hold
(
dev_out
);
fl
.
flowi
_oif
=
dev_out
->
ifindex
;
fl
d
.
flowidn
_oif
=
dev_out
->
ifindex
;
if
(
res
.
fi
)
dn_fib_info_put
(
res
.
fi
);
res
.
fi
=
NULL
;
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
&&
fl
d
.
flowidn
_oif
==
0
)
dn_fib_select_multipath
(
&
fl
d
,
&
res
);
/*
* We could add some logic to deal with default routes here and
* get rid of some of the special casing above.
*/
if
(
!
fl
.
fld_src
)
fl
.
fld_src
=
DN_FIB_RES_PREFSRC
(
res
);
if
(
!
fl
d
.
saddr
)
fl
d
.
saddr
=
DN_FIB_RES_PREFSRC
(
res
);
if
(
dev_out
)
dev_put
(
dev_out
);
dev_out
=
DN_FIB_RES_DEV
(
res
);
dev_hold
(
dev_out
);
fl
.
flowi
_oif
=
dev_out
->
ifindex
;
fl
d
.
flowidn
_oif
=
dev_out
->
ifindex
;
gateway
=
DN_FIB_RES_GW
(
res
);
make_route:
...
...
@@ -1131,19 +1132,19 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
atomic_set
(
&
rt
->
dst
.
__refcnt
,
1
);
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
->
fl
d
.
saddr
=
oldflp
->
saddr
;
rt
->
fl
d
.
daddr
=
oldflp
->
daddr
;
rt
->
fl
d
.
flowidn_oif
=
oldflp
->
flowidn
_oif
;
rt
->
fl
d
.
flowidn_iif
=
0
;
rt
->
fl
d
.
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
=
fl
d
.
saddr
;
rt
->
rt_daddr
=
fl
d
.
daddr
;
rt
->
rt_gateway
=
gateway
?
gateway
:
fl
d
.
daddr
;
rt
->
rt_local_src
=
fl
d
.
saddr
;
rt
->
rt_dst_map
=
fl
.
fld_dst
;
rt
->
rt_src_map
=
fl
.
fld_src
;
rt
->
rt_dst_map
=
fl
d
.
daddr
;
rt
->
rt_src_map
=
fl
d
.
saddr
;
rt
->
dst
.
dev
=
dev_out
;
dev_hold
(
dev_out
);
...
...
@@ -1161,7 +1162,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
if
(
err
)
goto
e_neighbour
;
hash
=
dn_hash
(
rt
->
fl
.
fld_src
,
rt
->
fl
.
fld_dst
);
hash
=
dn_hash
(
rt
->
fl
d
.
saddr
,
rt
->
fld
.
daddr
);
dn_insert_route
(
rt
,
hash
,
(
struct
dn_route
**
)
pprt
);
done:
...
...
@@ -1192,20 +1193,20 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
/*
* 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
flowi
dn
*
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
;
if
(
!
(
flags
&
MSG_TRYHARD
))
{
rcu_read_lock_bh
();
for
(
rt
=
rcu_dereference_bh
(
dn_rt_hash_table
[
hash
].
chain
);
rt
;
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
->
flowi
dn_mark
==
rt
->
fld
.
flowidn
_mark
)
&&
dn_is_output_route
(
rt
)
&&
(
rt
->
fl
.
flowi_oif
==
flp
->
flowi
_oif
))
{
(
rt
->
fl
d
.
flowidn_oif
==
flp
->
flowidn
_oif
))
{
dst_use
(
&
rt
->
dst
,
jiffies
);
rcu_read_unlock_bh
();
*
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
);
}
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
flowi
dn
*
flp
,
int
flags
)
{
int
err
;
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
))
{
err
=
PTR_ERR
(
*
pprt
);
*
pprt
=
NULL
;
...
...
@@ -1233,15 +1235,16 @@ static int dn_route_output_key(struct dst_entry **pprt, struct flowi *flp, int f
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
flowi
dn
*
fl
,
struct
sock
*
sk
,
int
flags
)
{
int
err
;
err
=
__dn_route_output_key
(
pprt
,
fl
,
flags
&
MSG_TRYHARD
);
if
(
err
==
0
&&
fl
->
flowi_proto
)
{
if
(
err
==
0
&&
fl
->
flowi
dn
_proto
)
{
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
))
{
err
=
PTR_ERR
(
*
pprt
);
*
pprt
=
NULL
;
...
...
@@ -1262,12 +1265,12 @@ static int dn_route_input_slow(struct sk_buff *skb)
int
flags
=
0
;
__le16
gateway
=
0
;
__le16
local_src
=
0
;
struct
flowi
fl
=
{
.
fld_dst
=
cb
->
dst
,
.
fld_src
=
cb
->
src
,
.
fl
d
_scope
=
RT_SCOPE_UNIVERSE
,
.
flowi_mark
=
skb
->
mark
,
.
flowi_iif
=
skb
->
dev
->
ifindex
,
struct
flowi
dn
fld
=
{
.
daddr
=
cb
->
dst
,
.
saddr
=
cb
->
src
,
.
fl
owidn
_scope
=
RT_SCOPE_UNIVERSE
,
.
flowi
dn
_mark
=
skb
->
mark
,
.
flowi
dn
_iif
=
skb
->
dev
->
ifindex
,
};
struct
dn_fib_res
res
=
{
.
fi
=
NULL
,
.
type
=
RTN_UNREACHABLE
};
int
err
=
-
EINVAL
;
...
...
@@ -1279,7 +1282,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
goto
out
;
/* Zero source addresses are not allowed */
if
(
fl
.
fld_src
==
0
)
if
(
fl
d
.
saddr
==
0
)
goto
out
;
/*
...
...
@@ -1293,7 +1296,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
if
(
dn_dev_islocal
(
in_dev
,
cb
->
src
))
goto
out
;
err
=
dn_fib_lookup
(
&
fl
,
&
res
);
err
=
dn_fib_lookup
(
&
fl
d
,
&
res
);
if
(
err
)
{
if
(
err
!=
-
ESRCH
)
goto
out
;
...
...
@@ -1305,7 +1308,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
res
.
type
=
RTN_LOCAL
;
}
else
{
__le16
src_map
=
fl
.
fld_src
;
__le16
src_map
=
fl
d
.
saddr
;
free_res
=
1
;
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
);
if
(
res
.
r
)
src_map
=
fl
.
fld_src
;
/* no NAT support for now */
src_map
=
fl
d
.
saddr
;
/* no NAT support for now */
gateway
=
DN_FIB_RES_GW
(
res
);
if
(
res
.
type
==
RTN_NAT
)
{
fl
.
fld_dst
=
dn_fib_rules_map_destination
(
fl
.
fld_dst
,
&
res
);
fl
d
.
daddr
=
dn_fib_rules_map_destination
(
fld
.
daddr
,
&
res
);
dn_fib_res_put
(
&
res
);
free_res
=
0
;
if
(
dn_fib_lookup
(
&
fl
,
&
res
))
if
(
dn_fib_lookup
(
&
fl
d
,
&
res
))
goto
e_inval
;
free_res
=
1
;
if
(
res
.
type
!=
RTN_UNICAST
)
goto
e_inval
;
flags
|=
RTCF_DNAT
;
gateway
=
fl
.
fld_dst
;
gateway
=
fl
d
.
daddr
;
}
fl
.
fld_src
=
src_map
;
fl
d
.
saddr
=
src_map
;
}
switch
(
res
.
type
)
{
...
...
@@ -1347,8 +1350,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
if
(
dn_db
->
parms
.
forwarding
==
0
)
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
&&
fl
d
.
flowidn
_oif
==
0
)
dn_fib_select_multipath
(
&
fl
d
,
&
res
);
/*
* 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
;
case
RTN_LOCAL
:
flags
|=
RTCF_LOCAL
;
fl
.
fld_src
=
cb
->
dst
;
fl
.
fld_dst
=
cb
->
src
;
fl
d
.
saddr
=
cb
->
dst
;
fl
d
.
daddr
=
cb
->
src
;
/* Routing tables gave us a gateway */
if
(
gateway
)
...
...
@@ -1400,21 +1403,21 @@ static int dn_route_input_slow(struct sk_buff *skb)
if
(
rt
==
NULL
)
goto
e_nobufs
;
rt
->
rt_saddr
=
fl
.
fld_src
;
rt
->
rt_daddr
=
fl
.
fld_dst
;
rt
->
rt_gateway
=
fl
.
fld_dst
;
rt
->
rt_saddr
=
fl
d
.
saddr
;
rt
->
rt_daddr
=
fl
d
.
daddr
;
rt
->
rt_gateway
=
fl
d
.
daddr
;
if
(
gateway
)
rt
->
rt_gateway
=
gateway
;
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
=
fl
d
.
daddr
;
rt
->
rt_src_map
=
fl
d
.
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
->
fl
d
.
saddr
=
cb
->
src
;
rt
->
fl
d
.
daddr
=
cb
->
dst
;
rt
->
fl
d
.
flowidn_oif
=
0
;
rt
->
fl
d
.
flowidn_iif
=
in_dev
->
ifindex
;
rt
->
fl
d
.
flowidn_mark
=
fld
.
flowidn
_mark
;
rt
->
dst
.
flags
=
DST_HOST
;
rt
->
dst
.
neighbour
=
neigh
;
...
...
@@ -1444,7 +1447,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
if
(
err
)
goto
e_neighbour
;
hash
=
dn_hash
(
rt
->
fl
.
fld_src
,
rt
->
fl
.
fld_dst
);
hash
=
dn_hash
(
rt
->
fl
d
.
saddr
,
rt
->
fld
.
daddr
);
dn_insert_route
(
rt
,
hash
,
&
rt
);
skb_dst_set
(
skb
,
&
rt
->
dst
);
...
...
@@ -1484,11 +1487,11 @@ static int dn_route_input(struct sk_buff *skb)
rcu_read_lock
();
for
(
rt
=
rcu_dereference
(
dn_rt_hash_table
[
hash
].
chain
);
rt
!=
NULL
;
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
->
fl
d
.
saddr
==
cb
->
src
)
&&
(
rt
->
fl
d
.
daddr
==
cb
->
dst
)
&&
(
rt
->
fl
d
.
flowidn
_oif
==
0
)
&&
(
rt
->
fl
d
.
flowidn
_mark
==
skb
->
mark
)
&&
(
rt
->
fl
d
.
flowidn
_iif
==
cb
->
iif
))
{
dst_use
(
&
rt
->
dst
,
jiffies
);
rcu_read_unlock
();
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
)
r
->
rtm_flags
|=
RTM_F_NOTIFY
;
RTA_PUT
(
skb
,
RTA_DST
,
2
,
&
rt
->
rt_daddr
);
if
(
rt
->
fl
.
fld_src
)
{
if
(
rt
->
fl
d
.
saddr
)
{
r
->
rtm_src_len
=
16
;
RTA_PUT
(
skb
,
RTA_SRC
,
2
,
&
rt
->
fl
.
fld_src
);
RTA_PUT
(
skb
,
RTA_SRC
,
2
,
&
rt
->
fl
d
.
saddr
);
}
if
(
rt
->
dst
.
dev
)
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
)
goto
rtattr_failure
;
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
->
fl
d
.
flowidn
_iif
);
nlh
->
nlmsg_len
=
skb_tail_pointer
(
skb
)
-
b
;
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
;
int
err
;
struct
sk_buff
*
skb
;
struct
flowi
fl
;
struct
flowi
dn
fld
;
if
(
!
net_eq
(
net
,
&
init_net
))
return
-
EINVAL
;
memset
(
&
fl
,
0
,
sizeof
(
fl
));
fl
.
flowi
_proto
=
DNPROTO_NSP
;
memset
(
&
fl
d
,
0
,
sizeof
(
fld
));
fl
d
.
flowidn
_proto
=
DNPROTO_NSP
;
skb
=
alloc_skb
(
NLMSG_GOODSIZE
,
GFP_KERNEL
);
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
);
if
(
rta
[
RTA_SRC
-
1
])
memcpy
(
&
fl
.
fld_src
,
RTA_DATA
(
rta
[
RTA_SRC
-
1
]),
2
);
memcpy
(
&
fl
d
.
saddr
,
RTA_DATA
(
rta
[
RTA_SRC
-
1
]),
2
);
if
(
rta
[
RTA_DST
-
1
])
memcpy
(
&
fl
.
fld_dst
,
RTA_DATA
(
rta
[
RTA_DST
-
1
]),
2
);
memcpy
(
&
fl
d
.
daddr
,
RTA_DATA
(
rta
[
RTA_DST
-
1
]),
2
);
if
(
rta
[
RTA_IIF
-
1
])
memcpy
(
&
fl
.
flowi
_iif
,
RTA_DATA
(
rta
[
RTA_IIF
-
1
]),
sizeof
(
int
));
memcpy
(
&
fl
d
.
flowidn
_iif
,
RTA_DATA
(
rta
[
RTA_IIF
-
1
]),
sizeof
(
int
));
if
(
fl
.
flowi
_iif
)
{
if
(
fl
d
.
flowidn
_iif
)
{
struct
net_device
*
dev
;
if
((
dev
=
dev_get_by_index
(
&
init_net
,
fl
.
flowi
_iif
))
==
NULL
)
{
if
((
dev
=
dev_get_by_index
(
&
init_net
,
fl
d
.
flowidn
_iif
))
==
NULL
)
{
kfree_skb
(
skb
);
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
->
dev
=
dev
;
cb
->
src
=
fl
.
fld_src
;
cb
->
dst
=
fl
.
fld_dst
;
cb
->
src
=
fl
d
.
saddr
;
cb
->
dst
=
fl
d
.
daddr
;
local_bh_disable
();
err
=
dn_route_input
(
skb
);
local_bh_enable
();
...
...
@@ -1615,8 +1618,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
int
oif
=
0
;
if
(
rta
[
RTA_OIF
-
1
])
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
);
fl
d
.
flowidn
_oif
=
oif
;
err
=
dn_route_output_key
((
struct
dst_entry
**
)
&
rt
,
&
fl
d
,
0
);
}
if
(
skb
->
dev
)
...
...
net/decnet/dn_rules.c
View file @
bef55aeb
...
...
@@ -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
flowi
dn
*
flp
,
struct
dn_fib_res
*
res
)
{
struct
fib_lookup_arg
arg
=
{
.
result
=
res
,
};
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
;
return
err
;
...
...
@@ -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
,
int
flags
,
struct
fib_lookup_arg
*
arg
)
{
struct
flowidn
*
fld
=
&
flp
->
u
.
dn
;
int
err
=
-
EAGAIN
;
struct
dn_fib_table
*
tbl
;
...
...
@@ -90,7 +92,7 @@ static int dn_fib_rule_action(struct fib_rule *rule, struct flowi *flp,
if
(
tbl
==
NULL
)
goto
errout
;
err
=
tbl
->
lookup
(
tbl
,
fl
p
,
(
struct
dn_fib_res
*
)
arg
->
result
);
err
=
tbl
->
lookup
(
tbl
,
fl
d
,
(
struct
dn_fib_res
*
)
arg
->
result
);
if
(
err
>
0
)
err
=
-
EAGAIN
;
errout:
...
...
@@ -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
)
{
struct
dn_fib_rule
*
r
=
(
struct
dn_fib_rule
*
)
rule
;
__le16
daddr
=
fl
->
fld_dst
;
__le16
saddr
=
fl
->
fld_src
;
struct
flowidn
*
fld
=
&
fl
->
u
.
dn
;
__le16
daddr
=
fld
->
daddr
;
__le16
saddr
=
fld
->
saddr
;
if
(((
saddr
^
r
->
src
)
&
r
->
srcmask
)
||
((
daddr
^
r
->
dst
)
&
r
->
dstmask
))
...
...
@@ -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
)
{
struct
flowi
fl
=
{
.
fld_dst
=
addr
};
struct
flowi
dn
fld
=
{
.
daddr
=
addr
};
struct
dn_fib_res
res
;
unsigned
ret
=
RTN_UNICAST
;
struct
dn_fib_table
*
tb
=
dn_fib_get_table
(
RT_TABLE_LOCAL
,
0
);
...
...
@@ -183,7 +186,7 @@ unsigned dnet_addr_type(__le16 addr)
res
.
r
=
NULL
;
if
(
tb
)
{
if
(
!
tb
->
lookup
(
tb
,
&
fl
,
&
res
))
{
if
(
!
tb
->
lookup
(
tb
,
&
fl
d
,
&
res
))
{
ret
=
res
.
type
;
dn_fib_res_put
(
&
res
);
}
...
...
net/decnet/dn_table.c
View file @
bef55aeb
...
...
@@ -764,7 +764,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb)
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
flowi
dn
*
flp
,
struct
dn_fib_res
*
res
)
{
int
err
;
struct
dn_zone
*
dz
;
...
...
@@ -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
);
for
(
dz
=
t
->
dh_zone_list
;
dz
;
dz
=
dz
->
dz_next
)
{
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
)
{
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,
if
(
f
->
fn_state
&
DN_S_ZOMBIE
)
continue
;
if
(
f
->
fn_scope
<
flp
->
fl
d
_scope
)
if
(
f
->
fn_scope
<
flp
->
fl
owidn
_scope
)
continue
;
err
=
dn_fib_semantic_match
(
f
->
fn_type
,
DN_FIB_INFO
(
f
),
flp
,
res
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment