netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: Remove attribute packed from struct 'action'
@ 2019-01-24 18:05 Mathieu Malaterre
  2019-01-24 18:08 ` Johannes Berg
  2019-01-24 18:19 ` [PATCH v2] mac80211: Add attribute aligned(2) to " Mathieu Malaterre
  0 siblings, 2 replies; 5+ messages in thread
From: Mathieu Malaterre @ 2019-01-24 18:05 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Mathieu Malaterre, Johannes Berg, David S. Miller,
	linux-wireless, netdev, linux-kernel

During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
follow-MAC mode") a new struct 'action' was declared with packed
attribute as:

  struct {
          struct ieee80211_hdr_3addr hdr;
          u8 category;
          u8 action_code;
  } __packed action;

But since struct 'ieee80211_hdr_3addr' is declared with an aligned
keyword as:

  struct ieee80211_hdr {
  	__le16 frame_control;
  	__le16 duration_id;
  	u8 addr1[ETH_ALEN];
  	u8 addr2[ETH_ALEN];
  	u8 addr3[ETH_ALEN];
  	__le16 seq_ctrl;
  	u8 addr4[ETH_ALEN];
  } __packed __aligned(2);

Solve the ambiguity of placing aligned structure in a packed one by
removing the packed attribute from struct. This seems to be the behavior
of gcc anyway, since the following is still compiling:

  BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);

This removes the following warning (W=1):

  net/mac80211/rx.c:234:2: warning: alignment 1 of 'struct <anonymous>' is less than 2 [-Wpacked-not-aligned]

Cc: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 net/mac80211/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 45aad3d3108c..709359650149 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -231,7 +231,7 @@ static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata,
 		struct ieee80211_hdr_3addr hdr;
 		u8 category;
 		u8 action_code;
-	} __packed action;
+	} action;
 
 	if (!sdata)
 		return;
-- 
2.19.2


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

* Re: [PATCH] mac80211: Remove attribute packed from struct 'action'
  2019-01-24 18:05 [PATCH] mac80211: Remove attribute packed from struct 'action' Mathieu Malaterre
@ 2019-01-24 18:08 ` Johannes Berg
  2019-01-24 18:14   ` Mathieu Malaterre
  2019-01-24 18:19 ` [PATCH v2] mac80211: Add attribute aligned(2) to " Mathieu Malaterre
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2019-01-24 18:08 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: David S. Miller, linux-wireless, netdev, linux-kernel

On Thu, 2019-01-24 at 19:05 +0100, Mathieu Malaterre wrote:
> During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
> follow-MAC mode") a new struct 'action' was declared with packed
> attribute as:
> 
>   struct {
>           struct ieee80211_hdr_3addr hdr;
>           u8 category;
>           u8 action_code;
>   } __packed action;
> 
> But since struct 'ieee80211_hdr_3addr' is declared with an aligned
> keyword as:
> 
>   struct ieee80211_hdr {
>   	__le16 frame_control;
>   	__le16 duration_id;
>   	u8 addr1[ETH_ALEN];
>   	u8 addr2[ETH_ALEN];
>   	u8 addr3[ETH_ALEN];
>   	__le16 seq_ctrl;
>   	u8 addr4[ETH_ALEN];
>   } __packed __aligned(2);
> 
> Solve the ambiguity of placing aligned structure in a packed one by
> removing the packed attribute from struct. This seems to be the behavior
> of gcc anyway, since the following is still compiling:
> 
>   BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);

I'm not sure this will work on all platforms, didn't something like
alpha pad out u8's to u32 when not requiring packing?

I guess I'd feel better about using __packed __aligned(2) here as well,
which should solve the warning too?

johannes



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

* Re: [PATCH] mac80211: Remove attribute packed from struct 'action'
  2019-01-24 18:08 ` Johannes Berg
@ 2019-01-24 18:14   ` Mathieu Malaterre
  2019-01-24 18:19     ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Malaterre @ 2019-01-24 18:14 UTC (permalink / raw)
  To: Johannes Berg; +Cc: David S. Miller, linux-wireless, netdev, LKML

On Thu, Jan 24, 2019 at 7:08 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> On Thu, 2019-01-24 at 19:05 +0100, Mathieu Malaterre wrote:
> > During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
> > follow-MAC mode") a new struct 'action' was declared with packed
> > attribute as:
> >
> >   struct {
> >           struct ieee80211_hdr_3addr hdr;
> >           u8 category;
> >           u8 action_code;
> >   } __packed action;
> >
> > But since struct 'ieee80211_hdr_3addr' is declared with an aligned
> > keyword as:
> >
> >   struct ieee80211_hdr {
> >       __le16 frame_control;
> >       __le16 duration_id;
> >       u8 addr1[ETH_ALEN];
> >       u8 addr2[ETH_ALEN];
> >       u8 addr3[ETH_ALEN];
> >       __le16 seq_ctrl;
> >       u8 addr4[ETH_ALEN];
> >   } __packed __aligned(2);
> >
> > Solve the ambiguity of placing aligned structure in a packed one by
> > removing the packed attribute from struct. This seems to be the behavior
> > of gcc anyway, since the following is still compiling:
> >
> >   BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);
>
> I'm not sure this will work on all platforms, didn't something like
> alpha pad out u8's to u32 when not requiring packing?

I was not aware of that.

> I guess I'd feel better about using __packed __aligned(2) here as well,
> which should solve the warning too?

Indeed, I will re-spin a v2 then.

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

* Re: [PATCH] mac80211: Remove attribute packed from struct 'action'
  2019-01-24 18:14   ` Mathieu Malaterre
@ 2019-01-24 18:19     ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2019-01-24 18:19 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: David S. Miller, linux-wireless, netdev, LKML

On Thu, 2019-01-24 at 19:14 +0100, Mathieu Malaterre wrote:

> > I'm not sure this will work on all platforms, didn't something like
> > alpha pad out u8's to u32 when not requiring packing?
> 
> I was not aware of that.

TBH, I'm not actually sure about that. Pure hearsay. If anyone knows,
I'd like to know too :)

johannes


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

* [PATCH v2] mac80211: Add attribute aligned(2) to struct 'action'
  2019-01-24 18:05 [PATCH] mac80211: Remove attribute packed from struct 'action' Mathieu Malaterre
  2019-01-24 18:08 ` Johannes Berg
@ 2019-01-24 18:19 ` Mathieu Malaterre
  1 sibling, 0 replies; 5+ messages in thread
From: Mathieu Malaterre @ 2019-01-24 18:19 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Mathieu Malaterre, Johannes Berg, David S. Miller,
	linux-wireless, netdev, linux-kernel

During refactor in commit 9e478066eae4 ("mac80211: fix MU-MIMO
follow-MAC mode") a new struct 'action' was declared with packed
attribute as:

  struct {
          struct ieee80211_hdr_3addr hdr;
          u8 category;
          u8 action_code;
  } __packed action;

But since struct 'ieee80211_hdr_3addr' is declared with an aligned
keyword as:

  struct ieee80211_hdr {
  	__le16 frame_control;
  	__le16 duration_id;
  	u8 addr1[ETH_ALEN];
  	u8 addr2[ETH_ALEN];
  	u8 addr3[ETH_ALEN];
  	__le16 seq_ctrl;
  	u8 addr4[ETH_ALEN];
  } __packed __aligned(2);

Solve the ambiguity of placing aligned structure in a packed one by
adding the aligned(2) attribute to struct 'action'. This seems to be the
behavior of gcc anyway, since the following is still compiling:

  BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1);

This removes the following warning (W=1):

  net/mac80211/rx.c:234:2: warning: alignment 1 of 'struct <anonymous>' is less than 2 [-Wpacked-not-aligned]

Cc: Johannes Berg <johannes.berg@intel.com>
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: It was suggested by Johannes that an arch actually need the pack attribute (alpha).

 net/mac80211/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 45aad3d3108c..885df250b67e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -231,7 +231,7 @@ static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata,
 		struct ieee80211_hdr_3addr hdr;
 		u8 category;
 		u8 action_code;
-	} __packed action;
+	} __packed __aligned(2) action;
 
 	if (!sdata)
 		return;
-- 
2.19.2


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

end of thread, other threads:[~2019-01-24 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 18:05 [PATCH] mac80211: Remove attribute packed from struct 'action' Mathieu Malaterre
2019-01-24 18:08 ` Johannes Berg
2019-01-24 18:14   ` Mathieu Malaterre
2019-01-24 18:19     ` Johannes Berg
2019-01-24 18:19 ` [PATCH v2] mac80211: Add attribute aligned(2) to " Mathieu Malaterre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).