mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-04 11:58:41 +00:00
Update tap targets without reinitializing packet source manager (#925)
This commit is contained in:
parent
763b0e7362
commit
99667984d6
@ -110,10 +110,8 @@ func UpdateTapTargets(newTapTargets []v1.Pod) {
|
|||||||
success := true
|
success := true
|
||||||
|
|
||||||
tapTargets = newTapTargets
|
tapTargets = newTapTargets
|
||||||
if err := initializePacketSources(); err != nil {
|
|
||||||
logger.Log.Fatal(err)
|
packetSourceManager.UpdatePods(tapTargets)
|
||||||
success = false
|
|
||||||
}
|
|
||||||
|
|
||||||
if tlsTapperInstance != nil {
|
if tlsTapperInstance != nil {
|
||||||
if err := tlstapper.UpdateTapTargets(tlsTapperInstance, &tapTargets, *procfs); err != nil {
|
if err := tlstapper.UpdateTapTargets(tlsTapperInstance, &tapTargets, *procfs); err != nil {
|
||||||
|
@ -11,8 +11,16 @@ import (
|
|||||||
const bpfFilterMaxPods = 150
|
const bpfFilterMaxPods = 150
|
||||||
const hostSourcePid = "0"
|
const hostSourcePid = "0"
|
||||||
|
|
||||||
|
type PacketSourceManagerConfig struct {
|
||||||
|
mtls bool
|
||||||
|
procfs string
|
||||||
|
interfaceName string
|
||||||
|
behaviour TcpPacketSourceBehaviour
|
||||||
|
}
|
||||||
|
|
||||||
type PacketSourceManager struct {
|
type PacketSourceManager struct {
|
||||||
sources map[string]*tcpPacketSource
|
sources map[string]*tcpPacketSource
|
||||||
|
config PacketSourceManagerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPacketSourceManager(procfs string, filename string, interfaceName string,
|
func NewPacketSourceManager(procfs string, filename string, interfaceName string,
|
||||||
@ -28,7 +36,14 @@ func NewPacketSourceManager(procfs string, filename string, interfaceName string
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceManager.UpdatePods(mtls, procfs, pods, interfaceName, behaviour)
|
sourceManager.config = PacketSourceManagerConfig{
|
||||||
|
mtls: mtls,
|
||||||
|
procfs: procfs,
|
||||||
|
interfaceName: interfaceName,
|
||||||
|
behaviour: behaviour,
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceManager.UpdatePods(pods)
|
||||||
return sourceManager, nil
|
return sourceManager, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,10 +64,9 @@ func newHostPacketSource(filename string, interfaceName string,
|
|||||||
return source, nil
|
return source, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PacketSourceManager) UpdatePods(mtls bool, procfs string, pods []v1.Pod,
|
func (m *PacketSourceManager) UpdatePods(pods []v1.Pod) {
|
||||||
interfaceName string, behaviour TcpPacketSourceBehaviour) {
|
if m.config.mtls {
|
||||||
if mtls {
|
m.updateMtlsPods(m.config.procfs, pods, m.config.interfaceName, m.config.behaviour)
|
||||||
m.updateMtlsPods(procfs, pods, interfaceName, behaviour)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.setBPFFilter(pods)
|
m.setBPFFilter(pods)
|
||||||
|
Loading…
Reference in New Issue
Block a user