Skip to content

Commit

Permalink
feat: add boolean "qinq" option to network interface spec
Browse files Browse the repository at this point in the history
If present and true, the `qinq` option will be added to the interface
network specification string in the minimega config.
  • Loading branch information
activeshadow committed Jun 28, 2023
1 parent 6b5c322 commit ac545d0
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/go/tmpl/templates/linux_interfaces.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if command -v 'ip' &>/dev/null; then
ip link set dev "$dev" down
ip addr flush dev "$dev"

{{ if eq $iface.Proto "manual" }}
{{ if or ($iface.QinQ) (eq $iface.Proto "manual") }}
ip link set dev "$dev" up
{{ else if eq $iface.Proto "dhcp" }}
ip link set dev "$dev" up
Expand All @@ -35,7 +35,7 @@ else
dev=$(ifconfig -s -a | grep -ivE '^lo|Iface' | awk 'NR=={{ addInt $idx 1 }} { print $1 }')
ifconfig "$dev" down

{{ if eq $iface.Proto "manual" }}
{{ if or ($iface.QinQ) (eq $iface.Proto "manual") }}
ifconfig "$dev" up
{{ else if eq $iface.Proto "dhcp" }}
ifconfig "$dev" up
Expand Down
2 changes: 1 addition & 1 deletion src/go/tmpl/templates/windows_startup.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Do {
} While ($wmi -eq $null)
{{ $length := len .Node.Network.Interfaces }}
{{ range $idx, $iface := .Node.Network.Interfaces }}
{{ if eq $iface.Proto "static" }}
{{ if and (eq $iface.Proto "static") (not $iface.QinQ) }}
Do {
{{ if gt $length 1 }}
$status = $wmi[{{ $idx }}].EnableStatic('{{ $iface.Address }}', '{{ $iface.NetworkMask }}')
Expand Down
2 changes: 2 additions & 0 deletions src/go/types/interfaces/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type NodeNetworkInterface interface {
Mask() int
Gateway() string
DNS() []string
QinQ() bool
RulesetIn() string
RulesetOut() string

Expand All @@ -128,6 +129,7 @@ type NodeNetworkInterface interface {
SetMask(int)
SetGateway(string)
SetDNS([]string)
SetQinQ(bool)
SetRulesetIn(string)
SetRulesetOut(string)
}
Expand Down
13 changes: 13 additions & 0 deletions src/go/types/version/v0/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type Interface struct {
MaskF int `json:"mask" yaml:"mask" structs:"mask" mapstructure:"mask"`
GatewayF string `json:"gateway" yaml:"gateway" structs:"gateway" mapstructure:"gateway"`
DNSF []string `json:"dns" yaml:"dns" structs:"dns" mapstructure:"dns"`
QinQF bool `json:"qinq" yaml:"qinq" structs:"qinq" mapstructure:"qinq"`
RulesetInF string `json:"ruleset_in" yaml:"ruleset_in" structs:"ruleset_in" mapstructure:"ruleset_in"`
RulesetOutF string `json:"ruleset_out" yaml:"ruleset_out" structs:"ruleset_out" mapstructure:"ruleset_out"`
}
Expand Down Expand Up @@ -162,6 +163,10 @@ func (this Interface) DNS() []string {
return this.DNSF
}

func (this Interface) QinQ() bool {
return this.QinQF
}

func (this Interface) RulesetIn() string {
return this.RulesetInF
}
Expand Down Expand Up @@ -230,6 +235,10 @@ func (this *Interface) SetDNS(dns []string) {
this.DNSF = dns
}

func (this *Interface) SetQinQ(q bool) {
this.QinQF = q
}

func (this *Interface) SetRulesetIn(rule string) {
this.RulesetInF = rule
}
Expand Down Expand Up @@ -480,6 +489,10 @@ func (this Network) InterfaceConfig() string {
config = append(config, iface.DriverF)
}

if iface.QinQF {
config = append(config, "qinq")
}

configs[i] = strings.Join(config, ",")
}

Expand Down
13 changes: 13 additions & 0 deletions src/go/types/version/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type Interface struct {
MaskF int `json:"mask" yaml:"mask" structs:"mask" mapstructure:"mask"`
GatewayF string `json:"gateway" yaml:"gateway" structs:"gateway" mapstructure:"gateway"`
DNSF []string `json:"dns" yaml:"dns" structs:"dns" mapstructure:"dns"`
QinQF bool `json:"qinq" yaml:"qinq" structs:"qinq" mapstructure:"qinq"`
RulesetInF string `json:"ruleset_in" yaml:"ruleset_in" structs:"ruleset_in" mapstructure:"ruleset_in"`
RulesetOutF string `json:"ruleset_out" yaml:"ruleset_out" structs:"ruleset_out" mapstructure:"ruleset_out"`
}
Expand Down Expand Up @@ -195,6 +196,10 @@ func (this Interface) DNS() []string {
return this.DNSF
}

func (this Interface) QinQ() bool {
return this.QinQF
}

func (this Interface) RulesetIn() string {
return this.RulesetInF
}
Expand Down Expand Up @@ -263,6 +268,10 @@ func (this *Interface) SetDNS(dns []string) {
this.DNSF = dns
}

func (this *Interface) SetQinQ(q bool) {
this.QinQF = q
}

func (this *Interface) SetRulesetIn(rule string) {
this.RulesetInF = rule
}
Expand Down Expand Up @@ -539,6 +548,10 @@ func (this Network) InterfaceConfig() string {
config = append(config, iface.DriverF)
}

if iface.QinQF {
config = append(config, "qinq")
}

configs[i] = strings.Join(config, ",")
}

Expand Down
3 changes: 3 additions & 0 deletions src/go/types/version/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ components:
driver:
type: string
example: e1000
qinq:
type: boolean
default: false
iface_address:
type: object
required:
Expand Down
3 changes: 3 additions & 0 deletions src/go/types/version/v2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ components:
driver:
type: string
example: e1000
qinq:
type: boolean
default: false
iface_address:
type: object
required:
Expand Down
8 changes: 7 additions & 1 deletion src/go/web/public/grapheditor/utils/schemas/kvm_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@
"type": "string",
"title": "proto",
"enum": [
"dhcp"
"dhcp",
"manual"
],
"default": "dhcp",
"examples": [
Expand Down Expand Up @@ -919,6 +920,11 @@
"examples": [
"e1000"
]
},
"qinq": {
"type": "boolean",
"title": "qinq",
"default": false
}
},
"required": [
Expand Down

0 comments on commit ac545d0

Please sign in to comment.