From 2e28b8e5db89aa876ce5b7666df6f63be1eef4c9 Mon Sep 17 00:00:00 2001 From: Numan Siddique Date: Thu, 26 Nov 2020 14:22:07 +0530 Subject: [PATCH] pinctrl: Fix segfault seen when creating mac_binding for local GARPs. Segfault is seen with the below trace. This patch fixes the issue by checking 'ovnsb_idl_txn' is not NULL before continuing in the function send_garp_locally(). #0 ovsdb_idl_txn_insert (txn=0x0, class=0x64b170 , uuid=0x0) at ../lib/ovsdb-idl.c:3504 #1 0x000000000041b068 in mac_binding_add (ovnsb_idl_txn=ovnsb_idl_txn@entry=0x0, sbrec_mac_binding_by_lport_ip=sbrec_mac_binding_by_lport_ip@entry=0xf6a7e0, logical_port=0xfd0d70 "lr0-pub", dp=0xfd0f20, ea=..., ip=0xf67be0 "172.24.4.221") at ../controller/pinctrl.c:3877 #2 0x000000000041b18b in send_garp_locally (ovnsb_idl_txn=ovnsb_idl_txn@entry=0x0, sbrec_mac_binding_by_lport_ip=sbrec_mac_binding_by_lport_ip@entry=0xf6a7e0, local_datapaths=local_datapaths@entry=0xf766f0, in_pb=in_pb@entry=0xfd3370, ea=..., ip=3708033196) at ../controller/pinctrl.c:3913 #3 0x000000000041d1be in send_garp_rarp_update (ovnsb_idl_txn=ovnsb_idl_txn@entry=0x0, sbrec_mac_binding_by_lport_ip=sbrec_mac_binding_by_lport_ip@entry=0xf6a7e0, local_datapaths=local_datapaths@entry=0xf766f0, binding_rec=0xfd3370, nat_addresses=nat_addresses@entry=0x7ffdb9295b80) at ../controller/pinctrl.c:4118 #4 0x0000000000425c88 in send_garp_rarp_prepare (active_tunnels=0xf76770, local_datapaths=0xf766f0, chassis=0xfdb4e0, br_int=, sbrec_mac_binding_by_lport_ip=0xf6a7e0, sbrec_port_binding_by_name=0xf6a090, sbrec_port_binding_by_datapath=, ovnsb_idl_txn=0x0) at ../controller/pinctrl.c:5491 #5 pinctrl_run (ovnsb_idl_txn=0x0, sbrec_datapath_binding_by_key=, sbrec_port_binding_by_datapath=, sbrec_port_binding_by_key=, sbrec_port_binding_by_name=0xf6a090, sbrec_mac_binding_by_lport_ip=0xf6a7e0, sbrec_igmp_groups=0xf6ab90, sbrec_ip_multicast_opts=0xf6a9c0, dns_table=0xf33960, ce_table=0xf33960, svc_mon_table=0xf33960, br_int=0xf67d50, chassis=0xfdb4e0, local_datapaths=0xf766f0, active_tunnels=0xf76770) at ../controller/pinctrl.c:3169 #6 0x0000000000408e91 in main (argc=, argv=) at ../controller/ovn-controller.c:2789 Fixes: a2b88dc51365("pinctrl: Directly update MAC_Bindings created by self originated GARPs.") Signed-off-by: Numan Siddique Acked-by: Dumitru Ceara --- controller/pinctrl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 919eae4f8..124892d70 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -3859,7 +3859,8 @@ mac_binding_lookup(struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip, return retval; } -/* Update or add an IP-MAC binding for 'logical_port'. */ +/* Update or add an IP-MAC binding for 'logical_port'. + * Caller should make sure that 'ovnsb_idl_txn' is valid. */ static void mac_binding_add(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip, @@ -3894,6 +3895,10 @@ send_garp_locally(struct ovsdb_idl_txn *ovnsb_idl_txn, const struct sbrec_port_binding *in_pb, struct eth_addr ea, ovs_be32 ip) { + if (!ovnsb_idl_txn) { + return; + } + const struct local_datapath *ldp = get_local_datapath(local_datapaths, in_pb->datapath->tunnel_key);