@@ -326,23 +326,25 @@ static int lan966x_port_prechangeupper(struct net_device *dev,
326326 return NOTIFY_DONE ;
327327}
328328
329- static int lan966x_foreign_bridging_check (struct net_device * bridge ,
329+ static int lan966x_foreign_bridging_check (struct net_device * upper ,
330+ bool * has_foreign ,
331+ bool * seen_lan966x ,
330332 struct netlink_ext_ack * extack )
331333{
332334 struct lan966x * lan966x = NULL ;
333- bool has_foreign = false;
334335 struct net_device * dev ;
335336 struct list_head * iter ;
336337
337- if (!netif_is_bridge_master (bridge ))
338+ if (!netif_is_bridge_master (upper ) &&
339+ !netif_is_lag_master (upper ))
338340 return 0 ;
339341
340- netdev_for_each_lower_dev (bridge , dev , iter ) {
342+ netdev_for_each_lower_dev (upper , dev , iter ) {
341343 if (lan966x_netdevice_check (dev )) {
342344 struct lan966x_port * port = netdev_priv (dev );
343345
344346 if (lan966x ) {
345- /* Bridge already has at least one port of a
347+ /* Upper already has at least one port of a
346348 * lan966x switch inside it, check that it's
347349 * the same instance of the driver.
348350 */
@@ -353,15 +355,24 @@ static int lan966x_foreign_bridging_check(struct net_device *bridge,
353355 }
354356 } else {
355357 /* This is the first lan966x port inside this
356- * bridge
358+ * upper device
357359 */
358360 lan966x = port -> lan966x ;
361+ * seen_lan966x = true;
359362 }
363+ } else if (netif_is_lag_master (dev )) {
364+ /* Allow to have bond interfaces that have only lan966x
365+ * devices
366+ */
367+ if (lan966x_foreign_bridging_check (dev , has_foreign ,
368+ seen_lan966x ,
369+ extack ))
370+ return - EINVAL ;
360371 } else {
361- has_foreign = true;
372+ * has_foreign = true;
362373 }
363374
364- if (lan966x && has_foreign ) {
375+ if (* seen_lan966x && * has_foreign ) {
365376 NL_SET_ERR_MSG_MOD (extack ,
366377 "Bridging lan966x ports with foreign interfaces disallowed" );
367378 return - EINVAL ;
@@ -374,7 +385,12 @@ static int lan966x_foreign_bridging_check(struct net_device *bridge,
374385static int lan966x_bridge_check (struct net_device * dev ,
375386 struct netdev_notifier_changeupper_info * info )
376387{
388+ bool has_foreign = false;
389+ bool seen_lan966x = false;
390+
377391 return lan966x_foreign_bridging_check (info -> upper_dev ,
392+ & has_foreign ,
393+ & seen_lan966x ,
378394 info -> info .extack );
379395}
380396
0 commit comments