mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-13 12:28:53 +00:00
cmd/lopower: add interface addresses to netstack
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
5865d33b41
commit
f7b6ff52b1
@ -9,6 +9,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -233,6 +234,24 @@ func (lp *lpServer) initNetstack(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
ns.SetPromiscuousMode(nicID, true)
|
ns.SetPromiscuousMode(nicID, true)
|
||||||
|
|
||||||
|
lp.mu.Lock()
|
||||||
|
v4, v6 := lp.c.V4, lp.c.V6
|
||||||
|
lp.mu.Unlock()
|
||||||
|
prefix := tcpip.AddrFrom4Slice(v4.AsSlice()).WithPrefix()
|
||||||
|
if tcpProb := ns.AddProtocolAddress(nicID, tcpip.ProtocolAddress{
|
||||||
|
Protocol: ipv4.ProtocolNumber,
|
||||||
|
AddressWithPrefix: prefix,
|
||||||
|
}, stack.AddressProperties{}); tcpProb != nil {
|
||||||
|
return errors.New(tcpProb.String())
|
||||||
|
}
|
||||||
|
prefix = tcpip.AddrFrom16Slice(v6.AsSlice()).WithPrefix()
|
||||||
|
if tcpProb := ns.AddProtocolAddress(nicID, tcpip.ProtocolAddress{
|
||||||
|
Protocol: ipv6.ProtocolNumber,
|
||||||
|
AddressWithPrefix: prefix,
|
||||||
|
}, stack.AddressProperties{}); tcpProb != nil {
|
||||||
|
return errors.New(tcpProb.String())
|
||||||
|
}
|
||||||
|
|
||||||
ipv4Subnet, err := tcpip.NewSubnet(tcpip.AddrFromSlice(make([]byte, 4)), tcpip.MaskFromBytes(make([]byte, 4)))
|
ipv4Subnet, err := tcpip.NewSubnet(tcpip.AddrFromSlice(make([]byte, 4)), tcpip.MaskFromBytes(make([]byte, 4)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create IPv4 subnet: %v", err)
|
return fmt.Errorf("could not create IPv4 subnet: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user