Set Interface Allmulti flag
This commit is contained in:
parent
de4d228950
commit
45b9ac5e86
@ -61,6 +61,7 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
|
||||
}
|
||||
go func() {
|
||||
<-stopChan
|
||||
setAllMulti(fd, iface, false)
|
||||
_ = syscall.Close(fd)
|
||||
stopWG.Done() // syscall.read does not release when the file descriptor is closed
|
||||
}()
|
||||
@ -77,6 +78,8 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
setAllMulti(fd, iface, true)
|
||||
|
||||
var protocolNo uint32
|
||||
if requestType == ndp_SOL {
|
||||
//Neighbor Solicitation
|
||||
@ -163,3 +166,28 @@ func listen(iface string, responder chan *ndpRequest, requestType ndpType, stopW
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type iflags struct {
|
||||
name [syscall.IFNAMSIZ]byte
|
||||
flags uint16
|
||||
}
|
||||
|
||||
func setAllMulti(fd int, iface string, enable bool) {
|
||||
var ifl iflags
|
||||
copy(ifl.name[:], []byte(iface))
|
||||
_, _, ep := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.SIOCGIFFLAGS, uintptr(unsafe.Pointer(&ifl)))
|
||||
if ep != 0 {
|
||||
panic(ep)
|
||||
}
|
||||
|
||||
if enable {
|
||||
ifl.flags |= uint16(syscall.IFF_ALLMULTI)
|
||||
} else {
|
||||
ifl.flags &^= uint16(syscall.IFF_ALLMULTI)
|
||||
}
|
||||
|
||||
_, _, ep = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifl)))
|
||||
if ep != 0 {
|
||||
panic(ep)
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ RestartSec=5s
|
||||
ExecStart=/usr/bin/pndpd config /etc/pndpd/pndpd.conf
|
||||
|
||||
DynamicUser=yes
|
||||
AmbientCapabilities=CAP_NET_RAW
|
||||
CapabilityBoundingSet=
|
||||
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
|
||||
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN
|
||||
ProtectHome=yes
|
||||
|
||||
[Install]
|
||||
|
Loading…
x
Reference in New Issue
Block a user