diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2022-04-05 09:49:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-05 09:49:00 -0400 |
| commit | 2c38c8ad35591849912a82db2f99f27001f55c01 (patch) | |
| tree | c9f98d14dc3ef53049c97665265586ae29043a5e | |
| parent | 0e3aad23de8a9fffbe8df81d660c8ebabe3497a9 (diff) | |
| parent | 2be18df4dc03b7c231f6a802c36beeca267ca5e5 (diff) | |
Merge pull request #10928 from anlancs/zebra-cleanup-1
zebra: use "assert" instead of unnecessary check
| -rw-r--r-- | zebra/rt_netlink.c | 2 | ||||
| -rw-r--r-- | zebra/zebra_evpn.c | 23 | ||||
| -rw-r--r-- | zebra/zebra_vxlan.c | 20 |
3 files changed, 16 insertions, 29 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f2cf9122fa..2ff083dec5 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -3273,7 +3273,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); - if ((NDA_VLAN <= NDA_MAX) && tb[NDA_VLAN]) { + if (tb[NDA_VLAN]) { vid_present = 1; vid = *(uint16_t *)RTA_DATA(tb[NDA_VLAN]); snprintf(vid_buf, sizeof(vid_buf), " VLAN %u", vid); diff --git a/zebra/zebra_evpn.c b/zebra/zebra_evpn.c index d9d21462fb..d223a21eda 100644 --- a/zebra/zebra_evpn.c +++ b/zebra/zebra_evpn.c @@ -649,10 +649,9 @@ static int zebra_evpn_map_vlan_ns(struct ns *ns, struct zebra_l2info_vxlan *vxl = NULL; struct zebra_from_svi_param *in_param = (struct zebra_from_svi_param *)_in_param; - int found = 0; - if (!in_param) - return NS_WALK_STOP; + assert(p_zevpn && in_param); + br_if = in_param->br_if; zif = in_param->zif; assert(zif); @@ -676,17 +675,13 @@ static int zebra_evpn_map_vlan_ns(struct ns *ns, if (!in_param->bridge_vlan_aware || vxl->access_vlan == in_param->vid) { - found = 1; - break; + zevpn = zebra_evpn_lookup(vxl->vni); + *p_zevpn = zevpn; + return NS_WALK_STOP; } } - if (!found) - return NS_WALK_CONTINUE; - zevpn = zebra_evpn_lookup(vxl->vni); - if (p_zevpn) - *p_zevpn = zevpn; - return NS_WALK_STOP; + return NS_WALK_CONTINUE; } /* @@ -831,8 +826,7 @@ static int zvni_map_to_macvlan_ns(struct ns *ns, struct interface *tmp_if = NULL; struct zebra_if *zif; - if (!in_param) - return NS_WALK_STOP; + assert(in_param && p_ifp); /* Identify corresponding VLAN interface. */ for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { @@ -846,8 +840,7 @@ static int zvni_map_to_macvlan_ns(struct ns *ns, continue; if (zif->link == in_param->svi_if) { - if (p_ifp) - *p_ifp = tmp_if; + *p_ifp = tmp_if; return NS_WALK_STOP; } } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 004c89bfa7..fc7eb8c87a 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -1754,6 +1754,8 @@ static int zl3vni_map_to_vxlan_if_ns(struct ns *ns, if (!zvrf) return NS_WALK_STOP; + assert(_pifp); + /* loop through all vxlan-interface */ for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { @@ -1784,8 +1786,7 @@ static int zl3vni_map_to_vxlan_if_ns(struct ns *ns, zl3vni->local_vtep_ip = vxl->vtep_ip; - if (_pifp) - *_pifp = (void *)ifp; + *_pifp = (void *)ifp; return NS_WALK_STOP; } @@ -1856,7 +1857,6 @@ struct zebra_l3vni *zl3vni_from_vrf(vrf_id_t vrf_id) static int zl3vni_from_svi_ns(struct ns *ns, void *_in_param, void **_p_zl3vni) { - int found = 0; struct zebra_ns *zns = ns->info; struct zebra_l3vni **p_zl3vni = (struct zebra_l3vni **)_p_zl3vni; struct zebra_from_svi_param *in_param = @@ -1866,8 +1866,7 @@ static int zl3vni_from_svi_ns(struct ns *ns, void *_in_param, void **_p_zl3vni) struct zebra_if *zif = NULL; struct zebra_l2info_vxlan *vxl = NULL; - if (!in_param) - return NS_WALK_STOP; + assert(in_param && p_zl3vni); /* loop through all vxlan-interface */ for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { @@ -1886,17 +1885,12 @@ static int zl3vni_from_svi_ns(struct ns *ns, void *_in_param, void **_p_zl3vni) if (!in_param->bridge_vlan_aware || vxl->access_vlan == in_param->vid) { - found = 1; - break; + *p_zl3vni = zl3vni_lookup(vxl->vni); + return NS_WALK_STOP; } } - if (!found) - return NS_WALK_CONTINUE; - - if (p_zl3vni) - *p_zl3vni = zl3vni_lookup(vxl->vni); - return NS_WALK_STOP; + return NS_WALK_CONTINUE; } /* |
