1
0
mirror of https://github.com/osrg/gobgp.git synced 2024-05-11 05:55:10 +00:00

api: fix regression that match set option has no default value

The commit 000589f3c "api: Implement UpdatePolicy()" introduced
a regression: if match-set-options is not defined in config file,
gobgpd starts with error: failed to get policy info: not found...

This fix set match-set-options to default when needed.
This commit is contained in:
oc
2018-11-05 21:10:25 +08:00
committed by FUJITA Tomonori
parent 60202fccc4
commit 5ab45752ce
2 changed files with 189 additions and 184 deletions

View File

@ -546,14 +546,6 @@ def emit_enum(prefix, name, stmt, substmts, fd):
print(' %s: %d,' % (enum_name, i), file=fd)
print('}\n', file=fd)
print('func (v %s) ToInt() int {' % type_name, file=fd)
print('i, ok := %sToIntMap[v]' % type_name, file=fd)
print('if !ok {', file=fd)
print('return -1', file=fd)
print('}', file=fd)
print('return i', file=fd)
print('}', file=fd)
print('var IntTo%sMap = map[int]%s {' % (type_name, type_name), file=fd)
for i, sub in enumerate(substmts):
enum_name = '%s_%s' % (const_prefix, convert_const_prefix(sub.arg))
@ -580,6 +572,19 @@ def emit_enum(prefix, name, stmt, substmts, fd):
print(' return v', file=fd)
print('}', file=fd)
print('func (v %s) ToInt() int {' % type_name, file=fd)
print('_v := v.DefaultAsNeeded()')
print('i, ok := %sToIntMap[_v]' % type_name, file=fd)
else:
print('func (v %s) ToInt() int {' % type_name, file=fd)
print('i, ok := %sToIntMap[v]' % type_name, file=fd)
print('if !ok {', file=fd)
print('return -1', file=fd)
print('}', file=fd)
print('return i', file=fd)
print('}', file=fd)
def emit_typedef(ctx, mod, fd):
prefix = mod.i_prefix