Skip to content

Commit f4ef85b

Browse files
edumazetdavem330
authored andcommitted
ipv4: add a fib_type to fib_info
commit d2d68ba (ipv4: Cache input routes in fib_info nexthops.) introduced a regression for forwarding. This was hard to reproduce but the symptom was that packets were delivered to local host instead of being forwarded. David suggested to add fib_type to fib_info so that we dont inadvertently share same fib_info for different purposes. With help from Julian Anastasov who provided very helpful hints, reproduced here : <quote> Can it be a problem related to fib_info reuse from different routes. For example, when local IP address is created for subnet we have: broadcast 192.168.0.255 dev DEV proto kernel scope link src 192.168.0.1 192.168.0.0/24 dev DEV proto kernel scope link src 192.168.0.1 local 192.168.0.1 dev DEV proto kernel scope host src 192.168.0.1 The "dev DEV proto kernel scope link src 192.168.0.1" is a reused fib_info structure where we put cached routes. The result can be same fib_info for 192.168.0.255 and 192.168.0.0/24. RTN_BROADCAST is cached only for input routes. Incoming broadcast to 192.168.0.255 can be cached and can cause problems for traffic forwarded to 192.168.0.0/24. So, this patch should solve the problem because it separates the broadcast from unicast traffic. And the ip_route_input_slow caching will work for local and broadcast input routes (above routes 1 and 3) just because they differ in scope and use different fib_info. </quote> Many thanks to Chris Clayton for his patience and help. Reported-by: Chris Clayton <chris2553@googlemail.com> Bisected-by: Chris Clayton <chris2553@googlemail.com> Reported-by: Dave Jones <davej@redhat.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Julian Anastasov <ja@ssi.bg> Tested-by: Chris Clayton <chris2553@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c0b8b99 commit f4ef85b

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎include/net/ip_fib.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct fib_info {
102102
unsigned char fib_dead;
103103
unsigned char fib_protocol;
104104
unsigned char fib_scope;
105+
unsigned char fib_type;
105106
__be32 fib_prefsrc;
106107
u32 fib_priority;
107108
u32 *fib_metrics;

‎net/ipv4/fib_semantics.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static struct fib_info *fib_find_info(const struct fib_info *nfi)
314314
nfi->fib_scope == fi->fib_scope &&
315315
nfi->fib_prefsrc == fi->fib_prefsrc &&
316316
nfi->fib_priority == fi->fib_priority &&
317+
nfi->fib_type == fi->fib_type &&
317318
memcmp(nfi->fib_metrics, fi->fib_metrics,
318319
sizeof(u32) * RTAX_MAX) == 0 &&
319320
((nfi->fib_flags ^ fi->fib_flags) & ~RTNH_F_DEAD) == 0 &&
@@ -833,6 +834,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
833834
fi->fib_flags = cfg->fc_flags;
834835
fi->fib_priority = cfg->fc_priority;
835836
fi->fib_prefsrc = cfg->fc_prefsrc;
837+
fi->fib_type = cfg->fc_type;
836838

837839
fi->fib_nhs = nhs;
838840
change_nexthops(fi) {

0 commit comments

Comments
 (0)