Skip to content

Commit

Permalink
Check syntax of loopback interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hknutzen committed Jan 10, 2024
1 parent edebaa3 commit 4bb40ea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{$NEXT}}

- Removed support for EZVPN at Cisco devices.
- Syntax of loopback interfaces is checked more thoroughly.

6.065 2023-11-13 11:45:12+01:00 Europe/Berlin

Expand Down
4 changes: 4 additions & 0 deletions go/pkg/pass1/setup-objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,7 @@ func (c *spoc) setupInterface(v *ast.Attribute,
check(intf.owner != nil, "owner")
check(intf.loopback, "loopback")
check(vip, "vip")
intf.loopback = false
} else if vip {
// Attribute 'vip' is an alias for 'loopback'.
typ = "'vip'"
Expand Down Expand Up @@ -1853,6 +1854,9 @@ func (c *spoc) setupInterface(v *ast.Attribute,

// Automatically create a network for loopback interface.
if intf.loopback {
if !isSimpleName(nName) {
c.err("Invalid identifier in '%s' of '%s'", v.Name, r.name)
}
var shortName string
var fullName string

Expand Down
11 changes: 11 additions & 0 deletions go/testdata/ipv6/parser_ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,17 @@ Error: Can't resolve interface:r1.n1@vrf2 in user of service:s1
Error: Can't resolve interface:r.n.123.nn in user of service:s1
=END=
############################################################
=TITLE=Invalid name of loopback interface
=PARAMS=--ipv6
=INPUT=
router:r1 = {
interface:lo-::a01:203 = { ip = ::a01:203; loopback; }
}
=ERROR=
Error: Invalid identifier in 'interface:lo-::a01:203' of 'router:r1'
=END=
############################################################
=TITLE=Missing [any|all]
=TODO= No IPv6
Expand Down
10 changes: 10 additions & 0 deletions go/testdata/parser.t
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,16 @@ Error: Can't resolve interface:r1.n1@vrf2 in user of service:s1
Error: Can't resolve interface:r.n.123.nn in user of service:s1
=END=
############################################################
=TITLE=Invalid name of loopback interface
=INPUT=
router:r1 = {
interface:lo-10.1.2.3 = { ip = 10.1.2.3; loopback; }
}
=ERROR=
Error: Invalid identifier in 'interface:lo-10.1.2.3' of 'router:r1'
=END=
############################################################
=TITLE=Missing [any|all]
# No IPv6
Expand Down

0 comments on commit 4bb40ea

Please sign in to comment.