Compare commits

...

2 Commits

5 changed files with 47 additions and 14 deletions

View File

@ -182,7 +182,7 @@ func (t *S6SvcTree) NetdevIfaceDHCP(iface Iface, ipv int) *S6Svc {
NETDEV_EXECLINE_HEADER,
ExeclineDefine("INTERFACE", iface.Name),
"fdmove -c 2 1",
fmt.Sprintf("%s -i $INTERFACE -f -S", daemon),
fmt.Sprintf("%s -i $INTERFACE -f -S -R", daemon),
}, "\n")
l.ProducerFor = t.S6New("logger.udhcpc", &S6SvcTypes.Longrun)
@ -192,6 +192,29 @@ func (t *S6SvcTree) NetdevIfaceDHCP(iface Iface, ipv int) *S6Svc {
return l
}
func (t *S6SvcTree) NetdevIfaceWPASupplicant(iface Iface) *S6Svc {
svc_name := S6SvcName(fmt.Sprintf("interface.%s.wpa_supplicant", iface.Name)).Sanitize()
l := t.S6New(svc_name, &S6SvcTypes.Longrun)
var daemon = "wpa_supplicant"
l.Run = strings.Join([]string{
NETDEV_EXECLINE_HEADER,
ExeclineXDGConfig(),
ExeclineXDGEnvdirConfig(l.Name),
ExeclineDefine("INTERFACE", iface.Name),
ExeclineImportas("CONFIG", false, "${XDG_CONFIG_HOME}/wpa_supplicant/wpa_supplicant.conf"),
"fdmove -c 2 1",
fmt.Sprintf("%s -i $INTERFACE -dd -c $CONFIG", daemon),
}, "\n")
l.ProducerFor = t.S6New("logger.wpa_supplicant", &S6SvcTypes.Longrun)
l.S6Children(t.LinkIfaceService(iface.Name), t.S6New("bundle.wpa_supplicant.deps", &S6SvcTypes.Bundle))
t.NetdevDependBundleStage(iface.Name, "ready", l)
return l
}
func (t *S6SvcTree) netdevIfaceAddrTemplate(action, iface string, ipv int, addr netip.Prefix) string {
return strings.Join([]string{
NETDEV_EXECLINE_HEADER,
@ -276,7 +299,11 @@ func (t *S6SvcTree) netdevRouteTemplate(iface Iface, route Route) (up, down stri
cmd = append(cmd, "metric", "$METRIC")
}
if route.Vrf != nil && route.Vrf.Type == &NetdevIfTypes.Vrf {
// Table overrides VRF if defined
if route.Table != 0 {
lines = append(lines, ExeclineImportas("TABLE", false, fmt.Sprintf("%d", route.Table)))
cmd = append(cmd, "table", "$TABLE")
} else if route.Vrf != nil && route.Vrf.Type == &NetdevIfTypes.Vrf {
// Parent is VRF
lines = append(lines, ExeclineImportas("VRF", false, route.Vrf.Name))
cmd = append(cmd, "vrf", "$VRF")

View File

@ -23,7 +23,7 @@ func (i *Iface) NetdevIfaceAddAddr(addr string) (err error) {
return
}
func (i *Iface) NetdevIfaceAddRoute(def bool, route, r_type, via string, vrf *Iface, table *RouteTable, metric Metric) (err error) {
func (i *Iface) NetdevIfaceAddRoute(def bool, route, r_type, via string, vrf *Iface, table RouteTable, metric Metric) (err error) {
var (
r = Route{
Default: def,

20
misc.go
View File

@ -9,15 +9,17 @@ import (
var (
dummy_svc_blacklist = map[S6SvcName]interface{}{
"bundle.hw-coldplug": nil,
"module.8021q": nil,
"module.bonding": nil,
"module.bridge": nil,
"module.vrf": nil,
"module.ipv6": nil,
"module.wireguard": nil,
"mount.proc": nil,
"logger.udhcpc": nil,
"bundle.hw-coldplug": nil,
"module.8021q": nil,
"module.bonding": nil,
"module.bridge": nil,
"module.vrf": nil,
"module.ipv6": nil,
"module.wireguard": nil,
"mount.proc": nil,
"logger.udhcpc": nil,
"logger.wpa_supplicant": nil,
"bundle.wpa_supplicant.deps": nil,
}
)

View File

@ -98,6 +98,9 @@ func (t *S6SvcTree) ConfigureServices(i Iface) (r []*S6Svc) {
if i.DHCP.V6 {
r = append(r, t.NetdevIfaceDHCP(i, 6))
}
if i.WPA_Supplicant {
r = append(r, t.NetdevIfaceWPASupplicant(i))
}
for _, v := range i.Sysctls.V4 {
r = append(r, t.NetdevIfaceIpSysctl(i, 4, v))

View File

@ -38,7 +38,8 @@ type Iface struct {
Addresses []netip.Prefix // Addresses to be assigned to interface
Routes []Route // Routes to be assigned to interface
DHCP DHCP_IP // Should we start dhcp on this interface?
DHCP DHCP_IP // Should we start dhcp on this interface?
WPA_Supplicant bool // Should we start wpa_supplicant on this interface?
Properties []Property // List of properties of the interface, valid for many
Sysctls Sysctl_IP // Sysctls associated with this interface
@ -52,7 +53,7 @@ type Route struct {
Net netip.Prefix
Via netip.Addr
Vrf *Iface
Table *RouteTable
Table RouteTable
Metric Metric // Should be explicitly initialised to 1024
}