2019-07-28 15:53:03

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH] netfilter: add include guard to xt_connlabel.h

Add a header include guard just in case.

Signed-off-by: Masahiro Yamada <[email protected]>
---

include/uapi/linux/netfilter/xt_connlabel.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/netfilter/xt_connlabel.h b/include/uapi/linux/netfilter/xt_connlabel.h
index 2312f0ec07b2..323f0dfc2a4e 100644
--- a/include/uapi/linux/netfilter/xt_connlabel.h
+++ b/include/uapi/linux/netfilter/xt_connlabel.h
@@ -1,4 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef _UAPI_XT_CONNLABEL_H
+#define _UAPI_XT_CONNLABEL_H
+
#include <linux/types.h>

#define XT_CONNLABEL_MAXBIT 127
@@ -11,3 +15,5 @@ struct xt_connlabel_mtinfo {
__u16 bit;
__u16 options;
};
+
+#endif /* _UAPI_XT_CONNLABEL_H */
--
2.17.1



2019-07-29 00:10:04

by Florian Westphal

[permalink] [raw]
Subject: Re: [PATCH] netfilter: add include guard to xt_connlabel.h

Masahiro Yamada <[email protected]> wrote:
> Add a header include guard just in case.

Acked-by: Florian Westphal <[email protected]>

2019-07-29 14:27:41

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] netfilter: add include guard to xt_connlabel.h

On Mon, Jul 29, 2019 at 10:15 PM Pablo Neira Ayuso <[email protected]> wrote:
>
> On Mon, Jul 29, 2019 at 12:51:38AM +0900, Masahiro Yamada wrote:
> > Add a header include guard just in case.
>
> Applied to nf.git, thanks.
>
> BTW, is the _UAPI_ prefix really needed? I can see netfilter headers
> under include/uapi/ sometimes are prefixed by UAPI and sometimes not.


The _UAPI prefix will be useful when you happen to
add the corresponding kernel-space header
since it is often the case to have the same name headers
for kernel-space and uapi.



For example, compare the include guards of the following.

include/linux/kernel.h
include/uapi/linux/kernel.h


Or, if you want to see an example for netfilter,

include/linux/netfilter/xt_hashlimit.h
include/uapi/linux/netfilter/xt_hashlimit.h



I recommend to add _UAPI prefix to headers
under include/uapi/
to avoid include guard conflict.

The _UAPI prefix is ripped off by
scripts/headers_install.sh
when exported to user-space.



--
Best Regards
Masahiro Yamada

2019-07-29 16:05:06

by Pablo Neira Ayuso

[permalink] [raw]
Subject: Re: [PATCH] netfilter: add include guard to xt_connlabel.h

On Mon, Jul 29, 2019 at 12:51:38AM +0900, Masahiro Yamada wrote:
> Add a header include guard just in case.

Applied to nf.git, thanks.

BTW, is the _UAPI_ prefix really needed? I can see netfilter headers
under include/uapi/ sometimes are prefixed by UAPI and sometimes not.

Thanks.