diff mbox

[net-next,3/3] cfg80211: add MPLS and 802.21 classification

Message ID 1392202386-8826-4-git-send-email-sw@simonwunderlich.de (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Simon Wunderlich Feb. 12, 2014, 10:53 a.m. UTC
MPLS labels may contain traffic control information, which should be
evaluated and used by the wireless subsystem if present.

Also check for IEEE 802.21 which is always network control traffic.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
---
 net/wireless/util.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Joe Perches Feb. 12, 2014, 11:49 a.m. UTC | #1
On Wed, 2014-02-12 at 11:53 +0100, Simon Wunderlich wrote:
> MPLS labels may contain traffic control information, which should be
> evaluated and used by the wireless subsystem if present.

trivial notes:

> diff --git a/net/wireless/util.c b/net/wireless/util.c
[]
> @@ -11,6 +11,7 @@
>  #include <net/ip.h>
>  #include <net/dsfield.h>
>  #include <linux/if_vlan.h>
> +#include <uapi/linux/mpls.h>

Please try not to #include uapi files.

> @@ -710,6 +711,29 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
>  			return vlan_priority;
>  	}
>  
> +	if (skb_headlen(skb) >= sizeof(struct ethhdr)) {
> +		struct ethhdr *eh = (struct ethhdr *) skb->data;
> +		struct mpls_label_stack mpls_tmp, *mpls;
> +
> +		switch (eh->h_proto) {
> +		case __constant_htons(ETH_P_MPLS_UC):
> +		case __constant_htons(ETH_P_MPLS_MC):

__constant_ isn't necessary for these labels.

>  	switch (skb->protocol) {
>  	case htons(ETH_P_IP):
>  		dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;

like this, just case htons(ETH_<FOO>) is enough.


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Wunderlich Feb. 13, 2014, 10:46 a.m. UTC | #2
Hey Joe,

thanks for the comments!

> On Wed, 2014-02-12 at 11:53 +0100, Simon Wunderlich wrote:
> > MPLS labels may contain traffic control information, which should be
> > evaluated and used by the wireless subsystem if present.
> 
> trivial notes:
> > diff --git a/net/wireless/util.c b/net/wireless/util.c
> 
> []
> 
> > @@ -11,6 +11,7 @@
> > 
> >  #include <net/ip.h>
> >  #include <net/dsfield.h>
> >  #include <linux/if_vlan.h>
> > 
> > +#include <uapi/linux/mpls.h>
> 
> Please try not to #include uapi files.
> 

why not? The packet definition header has been put in UAPI, so I need that 
there ... or should we move that to some place else? Other protocol definition 
headers like IP, udp, tcp have been defined in uapi too the same way, so I 
figured that would be the right position.

> > @@ -710,6 +711,29 @@ unsigned int cfg80211_classify8021d(struct sk_buff
> > *skb,
> > 
> >  			return vlan_priority;
> >  	
> >  	}
> > 
> > +	if (skb_headlen(skb) >= sizeof(struct ethhdr)) {
> > +		struct ethhdr *eh = (struct ethhdr *) skb->data;
> > +		struct mpls_label_stack mpls_tmp, *mpls;
> > +
> > +		switch (eh->h_proto) {
> > +		case __constant_htons(ETH_P_MPLS_UC):
> 
> > +		case __constant_htons(ETH_P_MPLS_MC):
> __constant_ isn't necessary for these labels.
> 

OK, I will change that.

> >  	switch (skb->protocol) {
> >  	
> >  	case htons(ETH_P_IP):
> >  		dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
> 
> like this, just case htons(ETH_<FOO>) is enough.

OK.

I can rework and resend this particular patch - probably to linux wireless. If 
the other patches are ok, would you guys merge the first two patches to net-
next then?

Thanks,
    Simon
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches Feb. 13, 2014, 11:14 a.m. UTC | #3
On Thu, 2014-02-13 at 11:46 +0100, Simon Wunderlich wrote:

Hi Simon

> > On Wed, 2014-02-12 at 11:53 +0100, Simon Wunderlich wrote:
> > > MPLS labels may contain traffic control information, which should be
> > > evaluated and used by the wireless subsystem if present.
[]
> > > diff --git a/net/wireless/util.c b/net/wireless/util.c
[]
> > > +#include <uapi/linux/mpls.h>
> > 
> > Please try not to #include uapi files.
> why not? The packet definition header has been put in UAPI, so I need that 
> there ... or should we move that to some place else? Other protocol definition 
> headers like IP, udp, tcp have been defined in uapi to the same way, so I 
> figured that would be the right position.

It seems the practice is to have another include/<net|linux>/mpls.h
file that #includes the <uapi/linux/mpls.h>

For instance, look at:

include/linux/udp.h

It does #include <uapi/linux/udp.h>

All the other kernel sources use

#include <linux/udp.h>



--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/wireless/util.c b/net/wireless/util.c
index d39c371..98e3b11 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -11,6 +11,7 @@ 
 #include <net/ip.h>
 #include <net/dsfield.h>
 #include <linux/if_vlan.h>
+#include <uapi/linux/mpls.h>
 #include "core.h"
 #include "rdev-ops.h"
 
@@ -710,6 +711,29 @@  unsigned int cfg80211_classify8021d(struct sk_buff *skb,
 			return vlan_priority;
 	}
 
+	if (skb_headlen(skb) >= sizeof(struct ethhdr)) {
+		struct ethhdr *eh = (struct ethhdr *) skb->data;
+		struct mpls_label_stack mpls_tmp, *mpls;
+
+		switch (eh->h_proto) {
+		case __constant_htons(ETH_P_MPLS_UC):
+		case __constant_htons(ETH_P_MPLS_MC):
+			/* MPLS */
+			mpls = skb_header_pointer(skb, sizeof(*eh),
+						  sizeof(*mpls), &mpls_tmp);
+			if (!mpls)
+				break;
+
+			return (ntohl(mpls->entry) & MPLS_LS_TC_MASK)
+				>> MPLS_LS_TC_SHIFT;
+		case __constant_htons(ETH_P_80221):
+			/* 802.21 is always network control traffic */
+			return 7;
+		default:
+			break;
+		}
+	}
+
 	switch (skb->protocol) {
 	case htons(ETH_P_IP):
 		dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;