Skip to content

Commit c5de4ee

Browse files
lzf575SongZhen0704
authored andcommitted
feat: support match custom service without epc
1 parent 76de14a commit c5de4ee

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

server/libs/grpc/grpc_service.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (s *ServiceTable) QueryPodService(t *PlatformInfoTable, orgId uint16, podID
194194

195195
func (s *ServiceTable) QueryCustomService(epcID int32, isIPv6 bool, ip4 uint32, ip6 net.IP, serverPort uint16, podServiceId, podGroupId, l3DeviceId, podId, podClusterID uint32, l3DeviceType uint8, protocol layers.IPProtocol) uint32 {
196196
// for performance optimization, return directly. Since when epcID <= 0, there is no Service information.
197-
if epcID <= 0 {
197+
if epcID < 0 {
198198
return 0
199199
}
200200
// If server port is 0, protocol is also ignored
@@ -273,7 +273,24 @@ func (s *ServiceTable) QueryCustomService(epcID int32, isIPv6 bool, ip4 uint32,
273273
// secondary query without port
274274
if len(s.customServiceClusterIP6Table) != 0 && serverPort != 0 {
275275
serviceId = s.customServiceClusterIP6Table[genEpcIDIP6Key(epcID, ip6, 0)]
276+
if serviceId > 0 {
277+
return serviceId
278+
}
279+
}
280+
281+
// thirdly query without epc
282+
if len(s.customServiceClusterIP6PortTable) != 0 {
283+
serviceId = s.customServiceClusterIP6PortTable[genEpcIDIP6PortKey(0, ip6, serviceProtocol, serverPort)]
284+
if serviceId > 0 {
285+
return serviceId
286+
}
287+
}
288+
289+
// fourthly query without epc/port
290+
if len(s.customServiceClusterIP6Table) != 0 && serverPort != 0 {
291+
serviceId = s.customServiceClusterIP6Table[genEpcIDIP6Key(0, ip6, 0)]
276292
}
293+
277294
return serviceId
278295
}
279296

@@ -286,6 +303,20 @@ func (s *ServiceTable) QueryCustomService(epcID int32, isIPv6 bool, ip4 uint32,
286303

287304
if len(s.customServiceClusterIP4Table) > 0 && serverPort != 0 {
288305
serviceId = s.customServiceClusterIP4Table[genEpcIDIP4Key(epcID, ip4, 0)]
306+
if serviceId > 0 {
307+
return serviceId
308+
}
309+
}
310+
311+
if len(s.customServiceClusterIP4PortTable[serviceProtocol]) > 0 {
312+
serviceId = s.customServiceClusterIP4PortTable[serviceProtocol][genEpcIDIP4PortKey(0, ip4, serverPort)]
313+
if serviceId > 0 {
314+
return serviceId
315+
}
316+
}
317+
318+
if len(s.customServiceClusterIP4Table) > 0 && serverPort != 0 {
319+
serviceId = s.customServiceClusterIP4Table[genEpcIDIP4Key(0, ip4, 0)]
289320
}
290321

291322
return serviceId

0 commit comments

Comments
 (0)