Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ import (
"github.com/vishvananda/netlink"
)

const (
omitMTU = 0
deviceMTU = -1
)

var (
flagMTU = flag.Int(
"mtu",
omitMTU,
fmt.Sprintf("configure the MTU value that is sent. %d (default) = disable MTU option, %d = use MTU of the interface device, >0 = send the provided value as the MTU option.", omitMTU, deviceMTU),
)
flagLifeTime = flag.Duration("lifetime", (30 * time.Minute), "Lifetime (prefix valid time will be 3x lifetime).")
flagInterval = flag.Duration("interval", (5 * time.Minute), "Frequency of *un*solicitated RAs.")
errRetry = errors.New("retry")
Expand Down Expand Up @@ -81,6 +91,15 @@ func main() {
ll.Infof("Loglevel '%s'", ll.GetLevel())
ll.Infof("Sending RAs valid for %v every %v on interfaces matching %s", *flagLifeTime, *flagInterval, *flagTapRegex)
ll.Infof("Excluding %s from RAs", exclude)
if *flagMTU == deviceMTU {
ll.Infoln("MTU Option: interface determined")
} else if *flagMTU == omitMTU {
ll.Infoln("MTU Option disabled")
} else if *flagMTU > omitMTU {
ll.Infof("MTU Option: %v", *flagMTU)
} else {
ll.Infof("MTU Option: invalid value %d", *flagMTU)
}

if flagLifeTime.Seconds() < 3*(flagInterval.Seconds()) {
ll.Warnf(
Expand Down
7 changes: 6 additions & 1 deletion ra.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ func (t Tap) sendLoop(ctx context.Context, c *ndp.Conn) error {
Direction: ndp.Source,
Addr: t.Ifi.HardwareAddr,
},
ndp.NewMTU(uint32(t.Ifi.MTU)),
}

if *flagMTU == deviceMTU {
options = append(options, ndp.NewMTU(uint32(t.Ifi.MTU)))
} else if *flagMTU > omitMTU {
options = append(options, ndp.NewMTU(uint32(*flagMTU)))
}

if t.Prefix != nil {
Expand Down