[2/2] backports: update backport/backport-include/net/netlink.h
diff mbox series

Message ID 20190319060915.19849-3-acelan.kao@canonical.com
State New
Headers show
Series
  • backports: to make iwlwifi compile under v5.1-rc1
Related show

Commit Message

AceLan Kao March 19, 2019, 6:09 a.m. UTC
Add new macros introduced from
   23323289b154 netlink: reduce NLA_POLICY_NESTED{,_ARRAY} arguments

Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
---
 backport/backport-include/net/netlink.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Hauke Mehrtens March 19, 2019, 9:50 p.m. UTC | #1
On 3/19/19 7:09 AM, AceLan Kao wrote:
> Add new macros introduced from
>    23323289b154 netlink: reduce NLA_POLICY_NESTED{,_ARRAY} arguments
> 
> Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
> ---
>  backport/backport-include/net/netlink.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
> index 4af73631..6f6630ae 100644
> --- a/backport/backport-include/net/netlink.h
> +++ b/backport/backport-include/net/netlink.h
> @@ -59,10 +59,14 @@ struct backport_nla_policy {
>  #define NLA_POLICY_ETH_ADDR		NLA_POLICY_EXACT_LEN(ETH_ALEN)
>  #define NLA_POLICY_ETH_ADDR_COMPAT	NLA_POLICY_EXACT_LEN_WARN(ETH_ALEN)
>  
> -#define NLA_POLICY_NESTED(maxattr, policy) \
> +#define _NLA_POLICY_NESTED(maxattr, policy) \
>  	{ .type = NLA_NESTED, .validation_data = policy, .len = maxattr }
> -#define NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
> +#define _NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
>  	{ .type = NLA_NESTED_ARRAY, .validation_data = policy, .len = maxattr }
> +#define NLA_POLICY_NESTED(policy) \
> +	_NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
> +#define NLA_POLICY_NESTED_ARRAY(policy) \
> +	_NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
>  
>  #define __NLA_ENSURE(condition) (sizeof(char[1 - 2*!(condition)]) - 1)
>  #define NLA_ENSURE_INT_TYPE(tp)				\
> 

This is only added for kernel < 4.20, there is a ifdef around, there is
also a backport needed for kernel 4.20 till 5.0.

Hauke
--
To unsubscribe from this list: send the line "unsubscribe backports" in
AceLan Kao March 20, 2019, 2:34 a.m. UTC | #2
Right, I'll submit v2 soon.

Hauke Mehrtens <hauke@hauke-m.de> 於 2019年3月20日 週三 上午5:50寫道:
>
> On 3/19/19 7:09 AM, AceLan Kao wrote:
> > Add new macros introduced from
> >    23323289b154 netlink: reduce NLA_POLICY_NESTED{,_ARRAY} arguments
> >
> > Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
> > ---
> >  backport/backport-include/net/netlink.h | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
> > index 4af73631..6f6630ae 100644
> > --- a/backport/backport-include/net/netlink.h
> > +++ b/backport/backport-include/net/netlink.h
> > @@ -59,10 +59,14 @@ struct backport_nla_policy {
> >  #define NLA_POLICY_ETH_ADDR          NLA_POLICY_EXACT_LEN(ETH_ALEN)
> >  #define NLA_POLICY_ETH_ADDR_COMPAT   NLA_POLICY_EXACT_LEN_WARN(ETH_ALEN)
> >
> > -#define NLA_POLICY_NESTED(maxattr, policy) \
> > +#define _NLA_POLICY_NESTED(maxattr, policy) \
> >       { .type = NLA_NESTED, .validation_data = policy, .len = maxattr }
> > -#define NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
> > +#define _NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
> >       { .type = NLA_NESTED_ARRAY, .validation_data = policy, .len = maxattr }
> > +#define NLA_POLICY_NESTED(policy) \
> > +     _NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
> > +#define NLA_POLICY_NESTED_ARRAY(policy) \
> > +     _NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
> >
> >  #define __NLA_ENSURE(condition) (sizeof(char[1 - 2*!(condition)]) - 1)
> >  #define NLA_ENSURE_INT_TYPE(tp)                              \
> >
>
> This is only added for kernel < 4.20, there is a ifdef around, there is
> also a backport needed for kernel 4.20 till 5.0.
>
> Hauke
--
To unsubscribe from this list: send the line "unsubscribe backports" in

Patch
diff mbox series

diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
index 4af73631..6f6630ae 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -59,10 +59,14 @@  struct backport_nla_policy {
 #define NLA_POLICY_ETH_ADDR		NLA_POLICY_EXACT_LEN(ETH_ALEN)
 #define NLA_POLICY_ETH_ADDR_COMPAT	NLA_POLICY_EXACT_LEN_WARN(ETH_ALEN)
 
-#define NLA_POLICY_NESTED(maxattr, policy) \
+#define _NLA_POLICY_NESTED(maxattr, policy) \
 	{ .type = NLA_NESTED, .validation_data = policy, .len = maxattr }
-#define NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
+#define _NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
 	{ .type = NLA_NESTED_ARRAY, .validation_data = policy, .len = maxattr }
+#define NLA_POLICY_NESTED(policy) \
+	_NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
+#define NLA_POLICY_NESTED_ARRAY(policy) \
+	_NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
 
 #define __NLA_ENSURE(condition) (sizeof(char[1 - 2*!(condition)]) - 1)
 #define NLA_ENSURE_INT_TYPE(tp)				\