Skip to content

Commit bf32273

Browse files
committed
Fixed panic with v4 network to v46 auto interface
1 parent c91c46c commit bf32273

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

go/pkg/pass1/normalize-services.go

+3
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ func (c *spoc) normalizeSrcDstList(
246246
c.substituteAutoIntf(dstList, toGrp(expSrcList), ctx)
247247
addExtra(extraDstSrc)
248248

249+
if expSrcList == nil && expDstList == nil {
250+
return
251+
}
249252
resultPairs = append(resultPairs, [2]srvObjList{expSrcList, expDstList})
250253
resultPairs = append(resultPairs, extraResult...)
251254
}

go/testdata/export-netspoc/combined46.t

+89
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,49 @@ service:s1 = {
115115
}
116116
=END=
117117

118+
############################################################
119+
=TITLE=Service from auto interface, identical vor IPv4, IPv6
120+
=INPUT=
121+
area:all = { anchor = network:n1; owner = o; }
122+
owner:o = { admins = a1@example.com; }
123+
network:n1 = { ip = 10.1.1.0/24; ip6 = 2001:db8:1:1::/64; }
124+
network:n2 = { ip = 10.1.2.0/24; ip6 = 2001:db8:1:2::/64; }
125+
router:r1 = {
126+
managed;
127+
model = IOS;
128+
interface:n1 = { ip = 10.1.1.1; ip6 = 2001:db8:1:1::1; hardware = n1; }
129+
interface:n2 = { ip = 10.1.2.1; ip6 = 2001:db8:1:2::1; hardware = n2; }
130+
}
131+
service:s1 = {
132+
user = interface:r1.[auto];
133+
permit src = network:n1; dst = user; prt = tcp 22;
134+
}
135+
=OUTPUT=
136+
--services
137+
{
138+
"s1": {
139+
"details": {
140+
"owner": [
141+
"o"
142+
]
143+
},
144+
"rules": [
145+
{
146+
"action": "permit",
147+
"dst": [],
148+
"has_user": "dst",
149+
"prt": [
150+
"tcp 22"
151+
],
152+
"src": [
153+
"network:n1"
154+
]
155+
}
156+
]
157+
}
158+
}
159+
=END=
160+
118161
############################################################
119162
=TITLE=Split service from auto interface, identical vor IPv4, IPv6
120163
=INPUT=
@@ -187,6 +230,52 @@ service:s1 = {
187230
}
188231
=END=
189232

233+
############################################################
234+
=TITLE=IPv4 only network to dual stack auto interface
235+
=INPUT=
236+
area:all = { anchor = network:n1; owner = o; }
237+
owner:o = { admins = a1@example.com; }
238+
network:n1 = { ip = 10.1.1.0/24; }
239+
router:r0 = {
240+
interface:n1;
241+
interface:n2;
242+
}
243+
network:n2 = { ip = 10.1.2.0/24; ip6 = 2001:db8:1:2::/64; }
244+
router:r1 = {
245+
managed;
246+
model = IOS;
247+
interface:n2 = { ip = 10.1.2.1; ip6 = 2001:db8:1:2::1; hardware = n2; }
248+
}
249+
service:s1 = {
250+
user = interface:r1.[auto];
251+
permit src = network:n1; dst = user; prt = tcp 22;
252+
}
253+
=OUTPUT=
254+
--services
255+
{
256+
"s1": {
257+
"details": {
258+
"owner": [
259+
"o"
260+
]
261+
},
262+
"rules": [
263+
{
264+
"action": "permit",
265+
"dst": [],
266+
"has_user": "dst",
267+
"prt": [
268+
"tcp 22"
269+
],
270+
"src": [
271+
"network:n1"
272+
]
273+
}
274+
]
275+
}
276+
}
277+
=END=
278+
190279
############################################################
191280
=TITLE=Combined non matching aggregates in rule
192281
=INPUT=

0 commit comments

Comments
 (0)