BUGFIX on mac handling when none + BUGFIX on mac generation (+1 for jailside)

This commit is contained in:
yo 2024-02-11 10:17:31 +01:00
parent 4edd0b7414
commit 6ead474a78

View File

@ -810,7 +810,9 @@ func generateMAC(jail *Jail, nic string) ([]byte, []byte, error) {
} }
hsmac := append(prefix, suffix...) hsmac := append(prefix, suffix...)
jsmac := append(hsmac[:5], hsmac[5]+1) jsmac := make([]byte, 6)
copy(jsmac, hsmac)
jsmac[5] = jsmac[5] + 1
// Save MACs to config // Save MACs to config
pname := fmt.Sprintf("Config.%s_mac", strings.Title(nic)) pname := fmt.Sprintf("Config.%s_mac", strings.Title(nic))
@ -853,6 +855,12 @@ func setupVnetInterfaceHostSide(jail *Jail) ([]string, error) {
return []string{}, err return []string{}, err
} }
} else { } else {
if strings.EqualFold(val.String(), "none") {
hsmac, _, err = generateMAC(jail, nic)
if err != nil {
return []string{}, err
}
}
hsmac, err = hex.DecodeString(strings.Split(val.String(), " ")[0]) hsmac, err = hex.DecodeString(strings.Split(val.String(), " ")[0])
if err != nil { if err != nil {
return []string{}, fmt.Errorf("Error converting %s to hex\n", strings.Split(val.String(), " ")[0]) return []string{}, fmt.Errorf("Error converting %s to hex\n", strings.Split(val.String(), " ")[0])
@ -912,7 +920,9 @@ func setupVnetInterfaceJailSide(jail *Jail, hostepairs []string) error {
for _, i := range strings.Split(jail.Config.Ip4_addr, ",") { for _, i := range strings.Split(jail.Config.Ip4_addr, ",") {
v := strings.Split(i, "|") v := strings.Split(i, "|")
ip4s[v[0]] = v[1] if len(v) > 1 {
ip4s[v[0]] = v[1]
}
} }
for _, i := range strings.Split(jail.Config.Ip6_addr, ",") { for _, i := range strings.Split(jail.Config.Ip6_addr, ",") {
v := strings.Split(i, "|") v := strings.Split(i, "|")