Skip to content

Commit

Permalink
cmd/gobgp: fix parseEvpnMacAdvArgs
Browse files Browse the repository at this point in the history
default-gateway not being declared a reserved keyword led to evpn
macadv commands ending as "encap vxlan default-gateway" to fail parsing.

In that case, default-gateway was bundled with the previous argument.

To fix that, set default-gateway as a reserved keyword of paramFlag type.

While there, change the way we detect its existence later on, given that it now
exists in our reserved map m, if set.
  • Loading branch information
costasd committed Jun 6, 2023
1 parent a0e9ab2 commit 0cc8a98
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions cmd/gobgp/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,14 @@ func parseEvpnMacAdvArgs(args []string) (bgp.AddrPrefixInterface, []string, erro
return nil, nil, fmt.Errorf("%d args required at least, but got %d", req, len(args))
}
m, err := extractReserved(args, map[string]int{
"esi": paramList,
"etag": paramSingle,
"label": paramSingle,
"rd": paramSingle,
"rt": paramList,
"encap": paramSingle,
"router-mac": paramSingle})
"esi": paramList,
"etag": paramSingle,
"label": paramSingle,
"rd": paramSingle,
"rt": paramList,
"encap": paramSingle,
"router-mac": paramSingle,
"default-gateway": paramFlag})
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -631,11 +632,8 @@ func parseEvpnMacAdvArgs(args []string) (bgp.AddrPrefixInterface, []string, erro
extcomms = append(extcomms, "router-mac", m["router-mac"][0])
}

for _, a := range args {
if a == "default-gateway" {
extcomms = append(extcomms, "default-gateway")
break
}
if _, ok := m["default-gateway"]; ok {
extcomms = append(extcomms, "default-gateway")
}

r := &bgp.EVPNMacIPAdvertisementRoute{
Expand Down

0 comments on commit 0cc8a98

Please sign in to comment.