BUGFIX setupVnetInterfaceJailSide
This commit is contained in:
parent
14984f417c
commit
549d517cf9
25
cmd/start.go
25
cmd/start.go
@ -899,7 +899,7 @@ func setupVnetInterfaceHostSide(jail *Jail) ([]string, error) {
|
|||||||
return epairs, nil
|
return epairs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupVnetInterfaceJailSide(jail *Jail) error {
|
func setupVnetInterfaceJailSide(jail *Jail, hostepairs []string) error {
|
||||||
var jsmac []byte
|
var jsmac []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -919,7 +919,7 @@ func setupVnetInterfaceJailSide(jail *Jail) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through configured interfaces
|
// Loop through configured interfaces
|
||||||
for _, nicCnf := range strings.Split(jail.Config.Interfaces, ",") {
|
for i, nicCnf := range strings.Split(jail.Config.Interfaces, ",") {
|
||||||
v := strings.Split(nicCnf, ":")
|
v := strings.Split(nicCnf, ":")
|
||||||
if len(v) != 2 {
|
if len(v) != 2 {
|
||||||
return fmt.Errorf("Invalid value for Interfaces: %s\n", nicCnf)
|
return fmt.Errorf("Invalid value for Interfaces: %s\n", nicCnf)
|
||||||
@ -930,6 +930,8 @@ func setupVnetInterfaceJailSide(jail *Jail) error {
|
|||||||
// inside jail final nic name
|
// inside jail final nic name
|
||||||
jnic := strings.Replace(v[0], "vnet", "epair", 1)
|
jnic := strings.Replace(v[0], "vnet", "epair", 1)
|
||||||
jnic = jnic + "b"
|
jnic = jnic + "b"
|
||||||
|
// host side associated jail nic name
|
||||||
|
jsepair := fmt.Sprintf("%sb", strings.TrimSuffix(hostepairs[i], "a"))
|
||||||
|
|
||||||
// Get jail side MAC
|
// Get jail side MAC
|
||||||
pname := fmt.Sprintf("Config.%s_mac", nic)
|
pname := fmt.Sprintf("Config.%s_mac", nic)
|
||||||
@ -948,7 +950,7 @@ func setupVnetInterfaceJailSide(jail *Jail) error {
|
|||||||
jsmac = val.Bytes()
|
jsmac = val.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := fmt.Sprintf("/sbin/ifconfig %s vnet %s", jnic, jail.InternalName)
|
cmd := fmt.Sprintf("/sbin/ifconfig %s vnet %s", jsepair, jail.InternalName)
|
||||||
_, err := executeCommand(cmd)
|
_, err := executeCommand(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error linking interface to jail: %v\n", err)
|
return fmt.Errorf("Error linking interface to jail: %v\n", err)
|
||||||
@ -960,14 +962,14 @@ func setupVnetInterfaceJailSide(jail *Jail) error {
|
|||||||
return fmt.Errorf("Error getting bridge %s mtu: %v\n", bridge, err)
|
return fmt.Errorf("Error getting bridge %s mtu: %v\n", bridge, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = fmt.Sprintf("/usr/sbin/jexec %d ifconfig %s mtu %d", jail.JID, jnic, mtu)
|
cmd = fmt.Sprintf("/usr/sbin/jexec %d ifconfig %s mtu %d", jail.JID, jsepair, mtu)
|
||||||
_, err = executeCommand(cmd)
|
_, err = executeCommand(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error setting mtu: %v\n", err)
|
return fmt.Errorf("Error setting mtu: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename epairXXb to epair0b (or opair1b, ...)
|
// rename epairXXb to epair0b (or opair1b, ...)
|
||||||
cmd = fmt.Sprintf("/usr/sbin/setfib %s jexec %d ifconfig %s name %s", jail.Config.Exec_fib, jail.JID, jnic, jnic)
|
cmd = fmt.Sprintf("/usr/sbin/setfib %s jexec %d ifconfig %s name %s", jail.Config.Exec_fib, jail.JID, jsepair, jnic)
|
||||||
_, err = executeCommand(cmd)
|
_, err = executeCommand(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error linking interface to jail: %v\n", err)
|
return fmt.Errorf("Error linking interface to jail: %v\n", err)
|
||||||
@ -1070,9 +1072,9 @@ func StartJailsAtBoot() {
|
|||||||
var curThNb int
|
var curThNb int
|
||||||
var curPri int
|
var curPri int
|
||||||
|
|
||||||
// Get boot enabled jails
|
// Get boot enabled non-template jails
|
||||||
for _, j := range gJails {
|
for _, j := range gJails {
|
||||||
if j.Config.Boot > 0 {
|
if j.Config.Boot > 0 && !strings.EqualFold(j.Config.Jailtype, "template") {
|
||||||
startList = append(startList, j)
|
startList = append(startList, j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1166,7 +1168,7 @@ func StartJail(args []string) {
|
|||||||
|
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
// Check if jail exist and is distinctly named
|
// Check if jail exist and is distinctly named
|
||||||
cj, err = getJailFromArray(a, []string{"jail"}, gJails)
|
cj, err = getJailFromArray(a, []string{"basejail", "jail"}, gJails)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error getting jail: %s\n", err)
|
fmt.Printf("Error getting jail: %s\n", err)
|
||||||
continue
|
continue
|
||||||
@ -1366,7 +1368,7 @@ func StartJail(args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Synchronize jail config to disk
|
// Synchronize jail config to disk
|
||||||
writeConfigToDisk(cj, false)
|
cj.WriteConfigToDisk(false)
|
||||||
|
|
||||||
start_cmd := fmt.Sprintf("/usr/sbin/jail -f /var/run/jail.%s.conf -c", cj.InternalName)
|
start_cmd := fmt.Sprintf("/usr/sbin/jail -f /var/run/jail.%s.conf -c", cj.InternalName)
|
||||||
|
|
||||||
@ -1416,13 +1418,13 @@ func StartJail(args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" > Setup VNet network:\n")
|
fmt.Printf(" > Setup VNet network:\n")
|
||||||
_, err = setupVnetInterfaceHostSide(cj);
|
hsepairs, err := setupVnetInterfaceHostSide(cj);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error setting VNet interface host side: %v\n", err)
|
fmt.Printf("Error setting VNet interface host side: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = setupVnetInterfaceJailSide(cj); err != nil {
|
if err = setupVnetInterfaceJailSide(cj, hsepairs); err != nil {
|
||||||
fmt.Printf("Error setting VNet interface jail side: %v\n", err)
|
fmt.Printf("Error setting VNet interface jail side: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1519,7 +1521,6 @@ func StartJail(args []string) {
|
|||||||
cj.Config.Last_started = curDate
|
cj.Config.Last_started = curDate
|
||||||
writeConfigToDisk(cj, false)
|
writeConfigToDisk(cj, false)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
|
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
|
||||||
if err == nil && len(out) > 0 {
|
if err == nil && len(out) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user