summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
authorHuawei LI <lihuawei_zzu@163.com>2022-09-29 11:28:12 +0800
committerNeale Ranns <neale@graphiant.com>2022-10-11 03:37:36 +0000
commit06923b33a9507ee6a92facb770650fff93d89dff (patch)
tree2952b05f1a800a7ed4cc07111c62ccb037471498 /src/vnet/fib
parent23b33ec02bb08b5998d3b2ba7c6ef7d4737424c6 (diff)
fib: fix crash when create vxlan/vxlan-gpe/geneve/gtpu tunnel.
Fix vpp crash when create vxlan/vxlan-gpe/geneve/gtpu tunnel with 0.0.0.0 dst ip in debug build. The ASSERT should be move out of fib_prefix_from_ip46_addr, which may be called when create vxlan/vxlan-gpe/geneve/gtpu tunnel with 0.0.0.0 dst ip. How to reproduce: 1. build debug vpp and run vpp 2. create vxlan t src 192.168.0.2 dst 0.0.0.0 vni 1 instance 1 create vxlan-gpe tunnel local 192.168.0.2 remote 0.0.0.0 vni 1 create geneve tunnel local 192.168.0.2 remote 0.0.0.0 vni 1 create gtpu tunnel src 192.168.0.2 dst 0.0.0.0 teid 1 Type: fix Change-Id: I19972f6af588f4ff7fd17de1b16b9301e43d596f Signed-off-by: Huawei LI <lihuawei_zzu@163.com>
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_path.c6
-rw-r--r--src/vnet/fib/fib_types.c13
-rw-r--r--src/vnet/fib/fib_types.h5
3 files changed, 14 insertions, 10 deletions
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index db78587fb27..8d160d99ccc 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -1998,7 +1998,11 @@ fib_path_resolve (fib_node_index_t path_index)
}
else
{
- fib_prefix_from_ip46_addr(&path->recursive.fp_nh.fp_ip, &pfx);
+ ASSERT(!ip46_address_is_zero(&path->recursive.fp_nh.fp_ip));
+
+ fib_protocol_t fp = (ip46_address_is_ip4(&path->recursive.fp_nh.fp_ip) ?
+ FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
+ fib_prefix_from_ip46_addr(fp, &path->recursive.fp_nh.fp_ip, &pfx);
}
fib_table_lock(path->recursive.fp_tbl_id,
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c
index 7eeb79fffa5..5c5fd0b9823 100644
--- a/src/vnet/fib/fib_types.c
+++ b/src/vnet/fib/fib_types.c
@@ -78,16 +78,15 @@ format_fib_mpls_label (u8 *s, va_list *ap)
}
void
-fib_prefix_from_ip46_addr (const ip46_address_t *addr,
+fib_prefix_from_ip46_addr (fib_protocol_t fproto,
+ const ip46_address_t *addr,
fib_prefix_t *pfx)
{
- ASSERT(!ip46_address_is_zero(addr));
+ ASSERT(FIB_PROTOCOL_MPLS != fproto);
- pfx->fp_proto = ((ip46_address_is_ip4(addr) ?
- FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6));
- pfx->fp_len = ((ip46_address_is_ip4(addr) ?
- 32 : 128));
+ pfx->fp_proto = fproto;
+ pfx->fp_len = ((FIB_PROTOCOL_IP4 == fproto) ?
+ 32 : 128);
pfx->fp_addr = *addr;
pfx->___fp___pad = 0;
}
diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h
index dbd4e97e867..49a4b39d042 100644
--- a/src/vnet/fib/fib_types.h
+++ b/src/vnet/fib/fib_types.h
@@ -276,8 +276,9 @@ extern void fib_prefix_normalize(const fib_prefix_t *p,
/**
* \brief Host prefix from ip
*/
-extern void fib_prefix_from_ip46_addr (const ip46_address_t *addr,
- fib_prefix_t *pfx);
+extern void fib_prefix_from_ip46_addr (fib_protocol_t fproto,
+ const ip46_address_t *addr,
+ fib_prefix_t *pfx);
extern u8 * format_fib_prefix(u8 * s, va_list * args);
extern u8 * format_fib_forw_chain_type(u8 * s, va_list * args);