All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] decouple llc/bridge
@ 2022-04-07 15:12 ` Dave Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Jones @ 2022-04-07 15:12 UTC (permalink / raw)
  To: netdev; +Cc: Roopa Prabhu, Nikolay Aleksandrov, bridge, Jakub Kicinski

I was wondering why the llc code was getting compiled and it turned out
to be because I had bridging enabled. It turns out to only needs it for
a single function (llc_mac_hdr_init).

Converting this to a static inline like the other llc functions it uses
allows to decouple the dependency

Signed-off-by: Dave Jones <davej@codemonkey.org.uk>

diff --git include/net/llc.h include/net/llc.h
index e250dca03963..edcb120ee6b0 100644
--- include/net/llc.h
+++ include/net/llc.h
@@ -13,6 +13,7 @@
  */
 
 #include <linux/if.h>
+#include <linux/if_arp.h>
 #include <linux/if_ether.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
@@ -100,8 +101,34 @@ extern struct list_head llc_sap_list;
 int llc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 	    struct net_device *orig_dev);
 
-int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa,
-		     const unsigned char *da);
+/**
+ *      llc_mac_hdr_init - fills MAC header fields
+ *      @skb: Address of the frame to initialize its MAC header
+ *      @sa: The MAC source address
+ *      @da: The MAC destination address
+ *
+ *      Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
+ *      is a valid type and initialization completes correctly 1, otherwise.
+ */
+static inline int llc_mac_hdr_init(struct sk_buff *skb,
+				   const unsigned char *sa, const unsigned char *da)
+{
+	int rc = -EINVAL;
+
+	switch (skb->dev->type) {
+	case ARPHRD_ETHER:
+	case ARPHRD_LOOPBACK:
+		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
+				     skb->len);
+		if (rc > 0)
+			rc = 0;
+		break;
+	default:
+		break;
+	}
+	return rc;
+}
+
 
 void llc_add_pack(int type,
 		  void (*handler)(struct llc_sap *sap, struct sk_buff *skb));
diff --git net/802/Kconfig net/802/Kconfig
index aaa83e888240..8bea5d1d5118 100644
--- net/802/Kconfig
+++ net/802/Kconfig
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config STP
 	tristate
-	select LLC
 
 config GARP
 	tristate
diff --git net/bridge/Kconfig net/bridge/Kconfig
index 3c8ded7d3e84..c011856d3386 100644
--- net/bridge/Kconfig
+++ net/bridge/Kconfig
@@ -5,7 +5,6 @@
 
 config BRIDGE
 	tristate "802.1d Ethernet Bridging"
-	select LLC
 	select STP
 	depends on IPV6 || IPV6=n
 	help
diff --git net/llc/llc_output.c net/llc/llc_output.c
index 5a6466fc626a..ad66886ed141 100644
--- net/llc/llc_output.c
+++ net/llc/llc_output.c
@@ -13,34 +13,6 @@
 #include <net/llc.h>
 #include <net/llc_pdu.h>
 
-/**
- *	llc_mac_hdr_init - fills MAC header fields
- *	@skb: Address of the frame to initialize its MAC header
- *	@sa: The MAC source address
- *	@da: The MAC destination address
- *
- *	Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
- *	is a valid type and initialization completes correctly 1, otherwise.
- */
-int llc_mac_hdr_init(struct sk_buff *skb,
-		     const unsigned char *sa, const unsigned char *da)
-{
-	int rc = -EINVAL;
-
-	switch (skb->dev->type) {
-	case ARPHRD_ETHER:
-	case ARPHRD_LOOPBACK:
-		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
-				     skb->len);
-		if (rc > 0)
-			rc = 0;
-		break;
-	default:
-		break;
-	}
-	return rc;
-}
-
 /**
  *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
  *	@sap: sap to use

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Bridge] [PATCH] decouple llc/bridge
@ 2022-04-07 15:12 ` Dave Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Jones @ 2022-04-07 15:12 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, Nikolay Aleksandrov, bridge, Roopa Prabhu

I was wondering why the llc code was getting compiled and it turned out
to be because I had bridging enabled. It turns out to only needs it for
a single function (llc_mac_hdr_init).

Converting this to a static inline like the other llc functions it uses
allows to decouple the dependency

Signed-off-by: Dave Jones <davej@codemonkey.org.uk>

diff --git include/net/llc.h include/net/llc.h
index e250dca03963..edcb120ee6b0 100644
--- include/net/llc.h
+++ include/net/llc.h
@@ -13,6 +13,7 @@
  */
 
 #include <linux/if.h>
+#include <linux/if_arp.h>
 #include <linux/if_ether.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
@@ -100,8 +101,34 @@ extern struct list_head llc_sap_list;
 int llc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 	    struct net_device *orig_dev);
 
-int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa,
-		     const unsigned char *da);
+/**
+ *      llc_mac_hdr_init - fills MAC header fields
+ *      @skb: Address of the frame to initialize its MAC header
+ *      @sa: The MAC source address
+ *      @da: The MAC destination address
+ *
+ *      Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
+ *      is a valid type and initialization completes correctly 1, otherwise.
+ */
+static inline int llc_mac_hdr_init(struct sk_buff *skb,
+				   const unsigned char *sa, const unsigned char *da)
+{
+	int rc = -EINVAL;
+
+	switch (skb->dev->type) {
+	case ARPHRD_ETHER:
+	case ARPHRD_LOOPBACK:
+		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
+				     skb->len);
+		if (rc > 0)
+			rc = 0;
+		break;
+	default:
+		break;
+	}
+	return rc;
+}
+
 
 void llc_add_pack(int type,
 		  void (*handler)(struct llc_sap *sap, struct sk_buff *skb));
diff --git net/802/Kconfig net/802/Kconfig
index aaa83e888240..8bea5d1d5118 100644
--- net/802/Kconfig
+++ net/802/Kconfig
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config STP
 	tristate
-	select LLC
 
 config GARP
 	tristate
diff --git net/bridge/Kconfig net/bridge/Kconfig
index 3c8ded7d3e84..c011856d3386 100644
--- net/bridge/Kconfig
+++ net/bridge/Kconfig
@@ -5,7 +5,6 @@
 
 config BRIDGE
 	tristate "802.1d Ethernet Bridging"
-	select LLC
 	select STP
 	depends on IPV6 || IPV6=n
 	help
diff --git net/llc/llc_output.c net/llc/llc_output.c
index 5a6466fc626a..ad66886ed141 100644
--- net/llc/llc_output.c
+++ net/llc/llc_output.c
@@ -13,34 +13,6 @@
 #include <net/llc.h>
 #include <net/llc_pdu.h>
 
-/**
- *	llc_mac_hdr_init - fills MAC header fields
- *	@skb: Address of the frame to initialize its MAC header
- *	@sa: The MAC source address
- *	@da: The MAC destination address
- *
- *	Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
- *	is a valid type and initialization completes correctly 1, otherwise.
- */
-int llc_mac_hdr_init(struct sk_buff *skb,
-		     const unsigned char *sa, const unsigned char *da)
-{
-	int rc = -EINVAL;
-
-	switch (skb->dev->type) {
-	case ARPHRD_ETHER:
-	case ARPHRD_LOOPBACK:
-		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
-				     skb->len);
-		if (rc > 0)
-			rc = 0;
-		break;
-	default:
-		break;
-	}
-	return rc;
-}
-
 /**
  *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
  *	@sap: sap to use

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] decouple llc/bridge
  2022-04-07 15:12 ` [Bridge] " Dave Jones
@ 2022-04-07 16:16   ` Stephen Hemminger
  -1 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2022-04-07 16:16 UTC (permalink / raw)
  To: Dave Jones
  Cc: netdev, Roopa Prabhu, Nikolay Aleksandrov, bridge, Jakub Kicinski

On Thu, 7 Apr 2022 11:12:17 -0400
Dave Jones <davej@codemonkey.org.uk> wrote:

> I was wondering why the llc code was getting compiled and it turned out
> to be because I had bridging enabled. It turns out to only needs it for
> a single function (llc_mac_hdr_init).
> 
> Converting this to a static inline like the other llc functions it uses
> allows to decouple the dependency
> 
> Signed-off-by: Dave Jones <davej@codemonkey.org.uk>
> 
> diff --git include/net/llc.h include/net/llc.h
> index e250dca03963..edcb120ee6b0 100644
> --- include/net/llc.h
> +++ include/net/llc.h
> @@ -13,6 +13,7 @@
>   */
>  
>  #include <linux/if.h>
> +#include <linux/if_arp.h>
>  #include <linux/if_ether.h>
>  #include <linux/list.h>
>  #include <linux/spinlock.h>
> @@ -100,8 +101,34 @@ extern struct list_head llc_sap_list;
>  int llc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
>  	    struct net_device *orig_dev);
>  
> -int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa,
> -		     const unsigned char *da);
> +/**
> + *      llc_mac_hdr_init - fills MAC header fields
> + *      @skb: Address of the frame to initialize its MAC header
> + *      @sa: The MAC source address
> + *      @da: The MAC destination address
> + *
> + *      Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
> + *      is a valid type and initialization completes correctly 1, otherwise.
> + */
> +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> +				   const unsigned char *sa, const unsigned char *da)
> +{
> +	int rc = -EINVAL;
> +
> +	switch (skb->dev->type) {
> +	case ARPHRD_ETHER:
> +	case ARPHRD_LOOPBACK:
> +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> +				     skb->len);
> +		if (rc > 0)
> +			rc = 0;
> +		break;
> +	default:
> +		break;
> +	}
> +	return rc;
> +}
> +
>  
>  void llc_add_pack(int type,
>  		  void (*handler)(struct llc_sap *sap, struct sk_buff *skb));
> diff --git net/802/Kconfig net/802/Kconfig
> index aaa83e888240..8bea5d1d5118 100644
> --- net/802/Kconfig
> +++ net/802/Kconfig
> @@ -1,7 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  config STP
>  	tristate
> -	select LLC
>  
>  config GARP
>  	tristate
> diff --git net/bridge/Kconfig net/bridge/Kconfig
> index 3c8ded7d3e84..c011856d3386 100644
> --- net/bridge/Kconfig
> +++ net/bridge/Kconfig
> @@ -5,7 +5,6 @@
>  
>  config BRIDGE
>  	tristate "802.1d Ethernet Bridging"
> -	select LLC
>  	select STP
>  	depends on IPV6 || IPV6=n
>  	help
> diff --git net/llc/llc_output.c net/llc/llc_output.c
> index 5a6466fc626a..ad66886ed141 100644
> --- net/llc/llc_output.c
> +++ net/llc/llc_output.c
> @@ -13,34 +13,6 @@
>  #include <net/llc.h>
>  #include <net/llc_pdu.h>
>  
> -/**
> - *	llc_mac_hdr_init - fills MAC header fields
> - *	@skb: Address of the frame to initialize its MAC header
> - *	@sa: The MAC source address
> - *	@da: The MAC destination address
> - *
> - *	Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
> - *	is a valid type and initialization completes correctly 1, otherwise.
> - */
> -int llc_mac_hdr_init(struct sk_buff *skb,
> -		     const unsigned char *sa, const unsigned char *da)
> -{
> -	int rc = -EINVAL;
> -
> -	switch (skb->dev->type) {
> -	case ARPHRD_ETHER:
> -	case ARPHRD_LOOPBACK:
> -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> -				     skb->len);
> -		if (rc > 0)
> -			rc = 0;
> -		break;
> -	default:
> -		break;
> -	}
> -	return rc;
> -}
> -
>  /**
>   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
>   *	@sap: sap to use

You may break other uses of LLC.

Why not open code as different function.  I used the llc stuff because there
were multiple copies of same code (DRY).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Bridge] [PATCH] decouple llc/bridge
@ 2022-04-07 16:16   ` Stephen Hemminger
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2022-04-07 16:16 UTC (permalink / raw)
  To: Dave Jones
  Cc: netdev, Nikolay Aleksandrov, bridge, Jakub Kicinski, Roopa Prabhu

On Thu, 7 Apr 2022 11:12:17 -0400
Dave Jones <davej@codemonkey.org.uk> wrote:

> I was wondering why the llc code was getting compiled and it turned out
> to be because I had bridging enabled. It turns out to only needs it for
> a single function (llc_mac_hdr_init).
> 
> Converting this to a static inline like the other llc functions it uses
> allows to decouple the dependency
> 
> Signed-off-by: Dave Jones <davej@codemonkey.org.uk>
> 
> diff --git include/net/llc.h include/net/llc.h
> index e250dca03963..edcb120ee6b0 100644
> --- include/net/llc.h
> +++ include/net/llc.h
> @@ -13,6 +13,7 @@
>   */
>  
>  #include <linux/if.h>
> +#include <linux/if_arp.h>
>  #include <linux/if_ether.h>
>  #include <linux/list.h>
>  #include <linux/spinlock.h>
> @@ -100,8 +101,34 @@ extern struct list_head llc_sap_list;
>  int llc_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
>  	    struct net_device *orig_dev);
>  
> -int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa,
> -		     const unsigned char *da);
> +/**
> + *      llc_mac_hdr_init - fills MAC header fields
> + *      @skb: Address of the frame to initialize its MAC header
> + *      @sa: The MAC source address
> + *      @da: The MAC destination address
> + *
> + *      Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
> + *      is a valid type and initialization completes correctly 1, otherwise.
> + */
> +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> +				   const unsigned char *sa, const unsigned char *da)
> +{
> +	int rc = -EINVAL;
> +
> +	switch (skb->dev->type) {
> +	case ARPHRD_ETHER:
> +	case ARPHRD_LOOPBACK:
> +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> +				     skb->len);
> +		if (rc > 0)
> +			rc = 0;
> +		break;
> +	default:
> +		break;
> +	}
> +	return rc;
> +}
> +
>  
>  void llc_add_pack(int type,
>  		  void (*handler)(struct llc_sap *sap, struct sk_buff *skb));
> diff --git net/802/Kconfig net/802/Kconfig
> index aaa83e888240..8bea5d1d5118 100644
> --- net/802/Kconfig
> +++ net/802/Kconfig
> @@ -1,7 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  config STP
>  	tristate
> -	select LLC
>  
>  config GARP
>  	tristate
> diff --git net/bridge/Kconfig net/bridge/Kconfig
> index 3c8ded7d3e84..c011856d3386 100644
> --- net/bridge/Kconfig
> +++ net/bridge/Kconfig
> @@ -5,7 +5,6 @@
>  
>  config BRIDGE
>  	tristate "802.1d Ethernet Bridging"
> -	select LLC
>  	select STP
>  	depends on IPV6 || IPV6=n
>  	help
> diff --git net/llc/llc_output.c net/llc/llc_output.c
> index 5a6466fc626a..ad66886ed141 100644
> --- net/llc/llc_output.c
> +++ net/llc/llc_output.c
> @@ -13,34 +13,6 @@
>  #include <net/llc.h>
>  #include <net/llc_pdu.h>
>  
> -/**
> - *	llc_mac_hdr_init - fills MAC header fields
> - *	@skb: Address of the frame to initialize its MAC header
> - *	@sa: The MAC source address
> - *	@da: The MAC destination address
> - *
> - *	Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
> - *	is a valid type and initialization completes correctly 1, otherwise.
> - */
> -int llc_mac_hdr_init(struct sk_buff *skb,
> -		     const unsigned char *sa, const unsigned char *da)
> -{
> -	int rc = -EINVAL;
> -
> -	switch (skb->dev->type) {
> -	case ARPHRD_ETHER:
> -	case ARPHRD_LOOPBACK:
> -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> -				     skb->len);
> -		if (rc > 0)
> -			rc = 0;
> -		break;
> -	default:
> -		break;
> -	}
> -	return rc;
> -}
> -
>  /**
>   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
>   *	@sap: sap to use

You may break other uses of LLC.

Why not open code as different function.  I used the llc stuff because there
were multiple copies of same code (DRY).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] decouple llc/bridge
  2022-04-07 16:16   ` [Bridge] " Stephen Hemminger
@ 2022-04-08  2:48     ` Jakub Kicinski
  -1 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-04-08  2:48 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Dave Jones, netdev, Roopa Prabhu, Nikolay Aleksandrov, bridge

On Thu, 7 Apr 2022 09:16:40 -0700 Stephen Hemminger wrote:
> > I was wondering why the llc code was getting compiled and it turned out
> > to be because I had bridging enabled. It turns out to only needs it for
> > a single function (llc_mac_hdr_init).

> > +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> > +				   const unsigned char *sa, const unsigned char *da)
> > +{
> > +	int rc = -EINVAL;
> > +
> > +	switch (skb->dev->type) {
> > +	case ARPHRD_ETHER:
> > +	case ARPHRD_LOOPBACK:
> > +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > +				     skb->len);
> > +		if (rc > 0)
> > +			rc = 0;
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +	return rc;
> > +}
> > +
> >  

nit: extra new line

> > -int llc_mac_hdr_init(struct sk_buff *skb,
> > -		     const unsigned char *sa, const unsigned char *da)
> > -{
> > -	int rc = -EINVAL;
> > -
> > -	switch (skb->dev->type) {
> > -	case ARPHRD_ETHER:
> > -	case ARPHRD_LOOPBACK:
> > -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > -				     skb->len);
> > -		if (rc > 0)
> > -			rc = 0;
> > -		break;
> > -	default:
> > -		break;
> > -	}
> > -	return rc;
> > -}

There's also an EXPORT somewhere in this file that has to go.

> >  /**
> >   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
> >   *	@sap: sap to use  
> 
> You may break other uses of LLC.
> 
> Why not open code as different function.  I used the llc stuff because there
> were multiple copies of same code (DRY).

I didn't quite get what you mean, Stephen, would you mind restating?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Bridge] [PATCH] decouple llc/bridge
@ 2022-04-08  2:48     ` Jakub Kicinski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-04-08  2:48 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: bridge, Dave Jones, Nikolay Aleksandrov, Roopa Prabhu, netdev

On Thu, 7 Apr 2022 09:16:40 -0700 Stephen Hemminger wrote:
> > I was wondering why the llc code was getting compiled and it turned out
> > to be because I had bridging enabled. It turns out to only needs it for
> > a single function (llc_mac_hdr_init).

> > +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> > +				   const unsigned char *sa, const unsigned char *da)
> > +{
> > +	int rc = -EINVAL;
> > +
> > +	switch (skb->dev->type) {
> > +	case ARPHRD_ETHER:
> > +	case ARPHRD_LOOPBACK:
> > +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > +				     skb->len);
> > +		if (rc > 0)
> > +			rc = 0;
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +	return rc;
> > +}
> > +
> >  

nit: extra new line

> > -int llc_mac_hdr_init(struct sk_buff *skb,
> > -		     const unsigned char *sa, const unsigned char *da)
> > -{
> > -	int rc = -EINVAL;
> > -
> > -	switch (skb->dev->type) {
> > -	case ARPHRD_ETHER:
> > -	case ARPHRD_LOOPBACK:
> > -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > -				     skb->len);
> > -		if (rc > 0)
> > -			rc = 0;
> > -		break;
> > -	default:
> > -		break;
> > -	}
> > -	return rc;
> > -}

There's also an EXPORT somewhere in this file that has to go.

> >  /**
> >   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
> >   *	@sap: sap to use  
> 
> You may break other uses of LLC.
> 
> Why not open code as different function.  I used the llc stuff because there
> were multiple copies of same code (DRY).

I didn't quite get what you mean, Stephen, would you mind restating?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] decouple llc/bridge
  2022-04-08  2:48     ` [Bridge] " Jakub Kicinski
@ 2022-04-08 15:41       ` Stephen Hemminger
  -1 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2022-04-08 15:41 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Dave Jones, netdev, Roopa Prabhu, Nikolay Aleksandrov, bridge

On Thu, 7 Apr 2022 19:48:59 -0700
Jakub Kicinski <kuba@kernel.org> wrote:

> On Thu, 7 Apr 2022 09:16:40 -0700 Stephen Hemminger wrote:
> > > I was wondering why the llc code was getting compiled and it turned out
> > > to be because I had bridging enabled. It turns out to only needs it for
> > > a single function (llc_mac_hdr_init).  
> 
> > > +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> > > +				   const unsigned char *sa, const unsigned char *da)
> > > +{
> > > +	int rc = -EINVAL;
> > > +
> > > +	switch (skb->dev->type) {
> > > +	case ARPHRD_ETHER:
> > > +	case ARPHRD_LOOPBACK:
> > > +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > > +				     skb->len);
> > > +		if (rc > 0)
> > > +			rc = 0;
> > > +		break;
> > > +	default:
> > > +		break;
> > > +	}
> > > +	return rc;
> > > +}
> > > +
> > >    
> 
> nit: extra new line
> 
> > > -int llc_mac_hdr_init(struct sk_buff *skb,
> > > -		     const unsigned char *sa, const unsigned char *da)
> > > -{
> > > -	int rc = -EINVAL;
> > > -
> > > -	switch (skb->dev->type) {
> > > -	case ARPHRD_ETHER:
> > > -	case ARPHRD_LOOPBACK:
> > > -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > > -				     skb->len);
> > > -		if (rc > 0)
> > > -			rc = 0;
> > > -		break;
> > > -	default:
> > > -		break;
> > > -	}
> > > -	return rc;
> > > -}  
> 
> There's also an EXPORT somewhere in this file that has to go.
> 
> > >  /**
> > >   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
> > >   *	@sap: sap to use    
> > 
> > You may break other uses of LLC.
> > 
> > Why not open code as different function.  I used the llc stuff because there
> > were multiple copies of same code (DRY).  
> 
> I didn't quite get what you mean, Stephen, would you mind restating?


Short answer: it was idea that didn't pan out.

Suggestion: get rid of using LLC  in bridge and just rewrite that one place.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Bridge] [PATCH] decouple llc/bridge
@ 2022-04-08 15:41       ` Stephen Hemminger
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2022-04-08 15:41 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: bridge, Dave Jones, Nikolay Aleksandrov, Roopa Prabhu, netdev

On Thu, 7 Apr 2022 19:48:59 -0700
Jakub Kicinski <kuba@kernel.org> wrote:

> On Thu, 7 Apr 2022 09:16:40 -0700 Stephen Hemminger wrote:
> > > I was wondering why the llc code was getting compiled and it turned out
> > > to be because I had bridging enabled. It turns out to only needs it for
> > > a single function (llc_mac_hdr_init).  
> 
> > > +static inline int llc_mac_hdr_init(struct sk_buff *skb,
> > > +				   const unsigned char *sa, const unsigned char *da)
> > > +{
> > > +	int rc = -EINVAL;
> > > +
> > > +	switch (skb->dev->type) {
> > > +	case ARPHRD_ETHER:
> > > +	case ARPHRD_LOOPBACK:
> > > +		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > > +				     skb->len);
> > > +		if (rc > 0)
> > > +			rc = 0;
> > > +		break;
> > > +	default:
> > > +		break;
> > > +	}
> > > +	return rc;
> > > +}
> > > +
> > >    
> 
> nit: extra new line
> 
> > > -int llc_mac_hdr_init(struct sk_buff *skb,
> > > -		     const unsigned char *sa, const unsigned char *da)
> > > -{
> > > -	int rc = -EINVAL;
> > > -
> > > -	switch (skb->dev->type) {
> > > -	case ARPHRD_ETHER:
> > > -	case ARPHRD_LOOPBACK:
> > > -		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
> > > -				     skb->len);
> > > -		if (rc > 0)
> > > -			rc = 0;
> > > -		break;
> > > -	default:
> > > -		break;
> > > -	}
> > > -	return rc;
> > > -}  
> 
> There's also an EXPORT somewhere in this file that has to go.
> 
> > >  /**
> > >   *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
> > >   *	@sap: sap to use    
> > 
> > You may break other uses of LLC.
> > 
> > Why not open code as different function.  I used the llc stuff because there
> > were multiple copies of same code (DRY).  
> 
> I didn't quite get what you mean, Stephen, would you mind restating?


Short answer: it was idea that didn't pan out.

Suggestion: get rid of using LLC  in bridge and just rewrite that one place.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-08 15:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 15:12 [PATCH] decouple llc/bridge Dave Jones
2022-04-07 15:12 ` [Bridge] " Dave Jones
2022-04-07 16:16 ` Stephen Hemminger
2022-04-07 16:16   ` [Bridge] " Stephen Hemminger
2022-04-08  2:48   ` Jakub Kicinski
2022-04-08  2:48     ` [Bridge] " Jakub Kicinski
2022-04-08 15:41     ` Stephen Hemminger
2022-04-08 15:41       ` [Bridge] " Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.