[Bug 1139] New: The include guards on the include/libipset/linux_ip_set*.h are wrong

bugzilla-daemon at netfilter.org bugzilla-daemon at netfilter.org
Tue Mar 28 21:27:15 CEST 2017


https://bugzilla.netfilter.org/show_bug.cgi?id=1139

            Bug ID: 1139
           Summary: The include guards on the
                    include/libipset/linux_ip_set*.h are wrong
           Product: ipset
           Version: unspecified
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: default
          Assignee: netfilter-buglog at lists.netfilter.org
          Reporter: quentin at armitage.org.uk

The header files include/libipset/linux_ip_set*.h are copies of the kernel
headers, which are be installed if kernel headers are installed. Since the two
sets of headers define the same things, it is necessary that the include guards
are the same so that including one stops the definitions etc from the other
being included. In some cases it is not possible to exclusively use either one
set of header files or the other, since it can be necessary, for example, to
include both libipset/session.h and linux/netfilter/xt_set.h and the former
includes libipset/linux_ip_set.h and the latter includes
linux/netfilter/ipset/ip_set.h.

Although in the kernel source code the headers include '_UAPI' as part of the
include guard define, it is removed as part of the processing by
scripts/headers_install.sh in the kernel source, which at aroundabout line 39
has the following:

-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \

which removes the _UAPI string prefix from the guard.

In order to resolve this, in the ipset top level Makefile.am, in
update_includes section, it needs to be changed from:

update_includes:
    for x in ip_set.h ip_set_bitmap.h ip_set_hash.h ip_set_list.h; do \
        cp kernel/include/uapi/linux/netfilter/ipset/$$x \
        include/libipset/linux_$$x; \
    done

to

update_includes:
    for x in ip_set.h ip_set_bitmap.h ip_set_hash.h ip_set_list.h; do \
        sed -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
                     kernel/include/uapi/linux/netfilter/ipset/$$x \
             >include/libipset/linux_$$x; \
    done

It is possible that the whole sed command from scripts/headers_install.sh
should be replicated in the ipset Makefile.am, viz:
        sed -r \
                -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
                -e 's/__attribute_const__([ \t]|$)/\1/g' \
                -e 's@^#include <linux/compiler.h>@@' \
                -e
's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
                -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
                -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \

but I think none of the other substitutions actually apply.

-- 
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.netfilter.org/pipermail/netfilter-buglog/attachments/20170328/197dd193/attachment.html>


More information about the netfilter-buglog mailing list