@@ -173,7 +173,7 @@ netdev_windows_system_construct(struct netdev *netdev_)
173
173
type = netdev_get_type (& netdev -> up );
174
174
if (type && !strcmp (type , "system" ) &&
175
175
(info .ovs_type == OVS_VPORT_TYPE_INTERNAL )) {
176
- VLOG_DBG ("construct device %s, ovs_type: %u failed" ,
176
+ VLOG_ERR ("construct device %s, ovs_type: %u failed" ,
177
177
netdev_get_name (& netdev -> up ), info .ovs_type );
178
178
return 1 ;
179
179
}
@@ -183,15 +183,18 @@ netdev_windows_system_construct(struct netdev *netdev_)
183
183
netdev -> port_no = info .port_no ;
184
184
185
185
netdev -> mac = info .mac_address ;
186
- netdev -> cache_valid = VALID_ETHERADDR ;
186
+ if (!eth_addr_is_zero (netdev -> mac )) {
187
+ netdev -> cache_valid = VALID_ETHERADDR ;
188
+ }
187
189
netdev -> ifindex = - EOPNOTSUPP ;
188
190
189
191
netdev -> mtu = info .mtu ;
190
192
netdev -> cache_valid |= VALID_MTU ;
191
193
192
194
netdev -> ifi_flags = dp_to_netdev_ifi_flags (info .ifi_flags );
193
- netdev -> cache_valid |= VALID_IFFLAG ;
194
-
195
+ if (netdev -> ifi_flags ) {
196
+ netdev -> cache_valid |= VALID_IFFLAG ;
197
+ }
195
198
VLOG_DBG ("construct device %s, ovs_type: %u." ,
196
199
netdev_get_name (& netdev -> up ), info .ovs_type );
197
200
return 0 ;
@@ -330,14 +333,40 @@ netdev_windows_get_etheraddr(const struct netdev *netdev_,
330
333
struct eth_addr * mac )
331
334
{
332
335
struct netdev_windows * netdev = netdev_windows_cast (netdev_ );
336
+ struct netdev_windows_netdev_info info ;
337
+ struct ofpbuf * buf = NULL ;
338
+ const char * type = NULL ;
339
+ const char * dev_name = NULL ;
340
+ int ret ;
333
341
334
- ovs_assert ((netdev -> cache_valid & VALID_ETHERADDR ) != 0 );
335
342
if (netdev -> cache_valid & VALID_ETHERADDR ) {
336
343
* mac = netdev -> mac ;
337
- } else {
338
- return EINVAL ;
344
+ return 0 ;
345
+ } else if (eth_addr_is_zero (netdev -> mac )) {
346
+ type = netdev_get_type (& netdev -> up );
347
+ if (type && !strcmp (type , "internal" )) {
348
+ dev_name = netdev_get_name (& netdev -> up );
349
+ if (dev_name ) {
350
+ ret = query_netdev (dev_name , & info , & buf );
351
+ if (!ret ) {
352
+ ofpbuf_delete (buf );
353
+ * mac = info .mac_address ;
354
+ if (!eth_addr_is_zero (info .mac_address )) {
355
+ netdev -> mac = info .mac_address ;
356
+ netdev -> cache_valid |= VALID_ETHERADDR ;
357
+ }
358
+ VLOG_DBG ("get_etheraddr query_netdev dev %s success" ,
359
+ dev_name );
360
+ return 0 ;
361
+ } else {
362
+ VLOG_ERR ("get_etheraddr query_netdev dev %s failed" ,
363
+ dev_name );
364
+ * mac = eth_addr_zero ;
365
+ }
366
+ }
367
+ }
339
368
}
340
- return 0 ;
369
+ return EINVAL ;
341
370
}
342
371
343
372
static int
@@ -363,24 +392,72 @@ netdev_windows_set_etheraddr(const struct netdev *netdev_,
363
392
return 0 ;
364
393
}
365
394
366
- /* This functionality is not really required by the datapath.
367
- * But vswitchd bringup expects this to be implemented. */
368
395
static int
369
396
netdev_windows_update_flags (struct netdev * netdev_ ,
370
397
enum netdev_flags off ,
371
398
enum netdev_flags on ,
372
399
enum netdev_flags * old_flagsp )
373
400
{
374
401
struct netdev_windows * netdev = netdev_windows_cast (netdev_ );
402
+ struct netdev_windows_netdev_info info ;
403
+ struct ofpbuf * buf = NULL ;
404
+ const char * type = NULL ;
405
+ const char * dev_name = NULL ;
406
+ uint32_t ifi_flags = 0 ;
407
+ int ret ;
408
+
409
+ type = netdev_get_type (& netdev -> up );
410
+ if (type && !strcmp (type , "internal" )) {
411
+ dev_name = netdev_get_name (& netdev -> up );
412
+ if (dev_name ) {
413
+ ret = query_netdev (dev_name , & info , & buf );
414
+ if (!ret ) {
415
+ ofpbuf_delete (buf );
416
+ ifi_flags = dp_to_netdev_ifi_flags (info .ifi_flags );
417
+ if (ifi_flags ) {
418
+ * old_flagsp = ifi_flags ;
419
+ netdev -> ifi_flags = ifi_flags ;
420
+ netdev -> cache_valid |= VALID_IFFLAG ;
421
+ }
422
+
423
+ if (eth_addr_is_zero (netdev -> mac ) &&
424
+ !eth_addr_is_zero (info .mac_address )) {
425
+ netdev -> mac = info .mac_address ;
426
+ netdev -> cache_valid |= VALID_ETHERADDR ;
427
+ }
428
+ VLOG_DBG ("update_flags query_netdev dev %s success: %d" ,
429
+ dev_name , * old_flagsp );
430
+ return 0 ;
431
+ } else {
432
+ VLOG_ERR ("update_flags query_netdev dev %s failed" ,
433
+ dev_name );
434
+ * old_flagsp = 0 ;
435
+ netdev -> ifi_flags = 0 ;
436
+ if (netdev -> cache_valid & VALID_IFFLAG ) {
437
+ netdev -> cache_valid &= ~VALID_IFFLAG ;
438
+ /* On ofproto_run() it will check port status
439
+ * for any port whose netdev has changed
440
+ * Here netdev_change_seq_changed would force do
441
+ * update_port()
442
+ */
443
+ netdev_change_seq_changed (& netdev -> up );
444
+ VLOG_INFO ("update_flags failed; update_port for %s" ,
445
+ dev_name );
446
+ }
447
+ if (!eth_addr_is_zero (netdev -> mac )) {
448
+ netdev -> mac = eth_addr_zero ;
449
+ netdev -> cache_valid &= ~VALID_ETHERADDR ;
450
+ }
451
+ return 0 ;
452
+ }
453
+ }
454
+ }
375
455
376
- ovs_assert ((netdev -> cache_valid & VALID_IFFLAG ) != 0 );
377
456
if (netdev -> cache_valid & VALID_IFFLAG ) {
378
457
* old_flagsp = netdev -> ifi_flags ;
379
- /* Setting the interface flags is not supported. */
380
- } else {
381
- return EINVAL ;
458
+ return 0 ;
382
459
}
383
- return 0 ;
460
+ return EINVAL ;
384
461
}
385
462
386
463
/* Looks up in the ARP table entry for a given 'ip'. If it is found, the
0 commit comments