@@ -186,16 +186,28 @@ func validateNetwork(yNetwork Network) error {
186
186
if err != nil {
187
187
return errors .Wrapf (err , "field `%s.url` %q failed stat" , field , vdeSwitch )
188
188
}
189
- if ! fi .IsDir () {
190
- return errors .Wrapf (err , "field `%s.url` %q is not a directory" , field , vdeSwitch )
191
- }
192
- ctlSocket := filepath .Join (vdeSwitch , "ctl" )
193
- fi , err = os .Stat (ctlSocket )
194
- if err != nil {
195
- return errors .Wrapf (err , "field `%s.url` control socket %q failed stat" , field , ctlSocket )
196
- }
197
- if fi .Mode ()& os .ModeSocket == 0 {
198
- return errors .Errorf ("field `%s.url` file %q is not a UNIX socket" , field , ctlSocket )
189
+ if fi .IsDir () {
190
+ /* Switch mode (vdeSwitch is dir, port != 65535) */
191
+ ctlSocket := filepath .Join (vdeSwitch , "ctl" )
192
+ fi , err = os .Stat (ctlSocket )
193
+ if err != nil {
194
+ return errors .Wrapf (err , "field `%s.url` control socket %q failed stat" , field , ctlSocket )
195
+ }
196
+ if fi .Mode ()& os .ModeSocket == 0 {
197
+ return errors .Errorf ("field `%s.url` file %q is not a UNIX socket" , field , ctlSocket )
198
+ }
199
+ if vde .SwitchPort == 65535 {
200
+ return errors .Errorf ("field `%s.url` points to a non-PTP switch, so the port number must not be 65535" , field )
201
+ }
202
+ } else {
203
+ /* PTP mode (vdeSwitch is socket, port == 65535) */
204
+ if fi .Mode ()& os .ModeSocket == 0 {
205
+ return errors .Errorf ("field `%s.url` %q is not a directory nor a UNIX socket" , field , vdeSwitch )
206
+ }
207
+ if vde .SwitchPort != 65535 {
208
+ return errors .Errorf ("field `%s.url` points to a PTP (switchless) socket %q, so the port number has to be 65535 (got %d)" ,
209
+ field , vdeSwitch , vde .SwitchPort )
210
+ }
199
211
}
200
212
} else if runtime .GOOS != "linux" {
201
213
logrus .Warnf ("field `%s.url` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)" ,
0 commit comments