]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
compiler: add and use __hidden visbility
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 17 Jul 2020 20:50:51 +0000 (22:50 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 17 Jul 2020 20:55:02 +0000 (22:55 +0200)
Closes: #3485.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/cmd/lxc_user_nic.c
src/lxc/compiler.h
src/lxc/nl.c
src/lxc/nl.h
src/lxc/rtnl.c
src/lxc/rtnl.h

index 473bca5c1dcc7c43a9f7930a592a9273de3dc465..10ef721e4f49c531bc0d89576446c779b062e4e4 100644 (file)
@@ -217,7 +217,6 @@ AM_CFLAGS = -DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
            -I $(top_srcdir)/src/lxc \
            -I $(top_srcdir)/src/lxc/storage \
            -I $(top_srcdir)/src/lxc/cgroups
-
 if ENABLE_APPARMOR
 AM_CFLAGS += -DHAVE_APPARMOR
 endif
@@ -409,6 +408,7 @@ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
                       log.c log.h \
                       memory_utils.h \
                       network.c network.h \
+                      nl.c nl.h \
                       parse.c parse.h \
                       process_utils.c process_utils.h \
                       syscall_numbers.h \
index 4160565f36b288dbcfd2d55af13fba6920feb34b..06f195a3768370d675bc0292e01a845b105ea186 100644 (file)
@@ -35,6 +35,7 @@
 #include "log.h"
 #include "memory_utils.h"
 #include "network.h"
+#include "nl.h"
 #include "parse.h"
 #include "process_utils.h"
 #include "string_utils.h"
index 114fb81baf67c41becbc71733d2639930a017b76..1852f1c0af1d6fb1ba9c6561a503b1cccea1d024 100644 (file)
@@ -75,4 +75,8 @@
 #endif
 #endif
 
+#ifndef __hidden
+#define __hidden __attribute__((visibility("hidden")))
+#endif
+
 #endif /* __LXC_COMPILER_H */
index dd94c09c886b1d5c81e728e28591ea8844971dee..81e9cbab4d87833d452a07344176b2306f492598 100644 (file)
@@ -19,7 +19,7 @@
 
 lxc_log_define(nl, lxc);
 
-size_t nlmsg_len(const struct nlmsg *nlmsg)
+static size_t nlmsg_len(const struct nlmsg *nlmsg)
 {
        return nlmsg->nlmsghdr->nlmsg_len - NLMSG_HDRLEN;
 }
index 7301ccf578f673062b9bb9284e5397e4633dbf7b..ab8368fe64109043b82ce539dc45f92e5312d123 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <stdio.h>
 
+#include "compiler.h"
 #include "memory_utils.h"
 
 /*
@@ -59,7 +60,7 @@ struct nlmsg {
  *
  * Return 0 on success, < 0 otherwise
  */
-int netlink_open(struct nl_handler *handler, int protocol);
+__hidden extern int netlink_open(struct nl_handler *handler, int protocol);
 
 /*
  * netlink_close : close a netlink socket, after this call,
@@ -67,7 +68,7 @@ int netlink_open(struct nl_handler *handler, int protocol);
  *
  * @handler: a handler to the netlink socket
  */
-void netlink_close(struct nl_handler *handler);
+__hidden extern void netlink_close(struct nl_handler *handler);
 define_cleanup_function(struct nl_handler *, netlink_close);
 
 /*
@@ -80,8 +81,8 @@ define_cleanup_function(struct nl_handler *, netlink_close);
  *
  * Returns 0 on success, < 0 otherwise
  */
-int netlink_rcv(struct nl_handler *handler, struct nlmsg *nlmsg);
-int __netlink_recv(struct nl_handler *handler, struct nlmsghdr *nlmsg);
+__hidden extern int netlink_rcv(struct nl_handler *handler, struct nlmsg *nlmsg);
+__hidden extern int __netlink_recv(struct nl_handler *handler, struct nlmsghdr *nlmsg);
 
 /*
  * netlink_send: send a netlink message to the kernel. It is up
@@ -92,8 +93,8 @@ int __netlink_recv(struct nl_handler *handler, struct nlmsghdr *nlmsg);
  *
  * Returns 0 on success, < 0 otherwise
  */
-int netlink_send(struct nl_handler *handler, struct nlmsg *nlmsg);
-int __netlink_send(struct nl_handler *handler, struct nlmsghdr *nlmsg);
+__hidden extern int netlink_send(struct nl_handler *handler, struct nlmsg *nlmsg);
+__hidden extern int __netlink_send(struct nl_handler *handler, struct nlmsghdr *nlmsg);
 
 /*
  * netlink_transaction: send a request to the kernel and read the response.
@@ -106,10 +107,10 @@ int __netlink_send(struct nl_handler *handler, struct nlmsghdr *nlmsg);
  *
  * Returns 0 on success, < 0 otherwise
  */
-int netlink_transaction(struct nl_handler *handler,
-                       struct nlmsg *request, struct nlmsg *answer);
-int __netlink_transaction(struct nl_handler *handler, struct nlmsghdr *request,
-                         struct nlmsghdr *answer);
+__hidden extern int netlink_transaction(struct nl_handler *handler, struct nlmsg *request,
+                                       struct nlmsg *answer);
+__hidden extern int __netlink_transaction(struct nl_handler *handler, struct nlmsghdr *request,
+                                         struct nlmsghdr *answer);
 
 /*
  * nla_put_string: copy a null terminated string to a netlink message
@@ -121,7 +122,7 @@ int __netlink_transaction(struct nl_handler *handler, struct nlmsghdr *request,
  *
  * Returns 0 on success, < 0 otherwise
  */
-int nla_put_string(struct nlmsg *nlmsg, int attr, const char *string);
+__hidden int nla_put_string(struct nlmsg *nlmsg, int attr, const char *string);
 
 /*
  * nla_put_buffer: copy a buffer with a specified size to a netlink
@@ -178,7 +179,7 @@ int nla_put_attr(struct nlmsg *nlmsg, int attr);
  * Returns current nested pointer to be reused
  * to nla_end_nested.
  */
-struct rtattr *nla_begin_nested(struct nlmsg *nlmsg, int attr);
+__hidden extern struct rtattr *nla_begin_nested(struct nlmsg *nlmsg, int attr);
 
 /*
  * nla_end_nested: end the nesting attribute
@@ -188,7 +189,7 @@ struct rtattr *nla_begin_nested(struct nlmsg *nlmsg, int attr);
  *
  * Returns the current
  */
-void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr);
+__hidden extern void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr);
 
 /*
  * nlmsg_allocate : allocate a netlink message. The netlink format message
@@ -205,7 +206,7 @@ void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr);
  *
  * Returns a pointer to the newly allocated netlink message, NULL otherwise
  */
-struct nlmsg *nlmsg_alloc(size_t size);
+__hidden extern struct nlmsg *nlmsg_alloc(size_t size);
 
 /*
  * nlmsg_alloc_reserve: like nlmsg_alloc(), but reserve the whole payload
@@ -214,7 +215,7 @@ struct nlmsg *nlmsg_alloc(size_t size);
  *
  * @size: the capacity of the payload to be allocated.
  */
-struct nlmsg *nlmsg_alloc_reserve(size_t size);
+__hidden extern struct nlmsg *nlmsg_alloc_reserve(size_t size);
 
 /*
  * Reserve room for additional data at the tail of a netlink message
@@ -224,14 +225,14 @@ struct nlmsg *nlmsg_alloc_reserve(size_t size);
  *
  * Returns a pointer to newly reserved room or NULL
  */
-void *nlmsg_reserve(struct nlmsg *nlmsg, size_t len);
+__hidden extern void *nlmsg_reserve(struct nlmsg *nlmsg, size_t len);
 
 /*
  * nlmsg_free : free a previously allocate message
  *
  * @nlmsg: the netlink message to be freed
  */
-void nlmsg_free(struct nlmsg *nlmsg);
+__hidden extern void nlmsg_free(struct nlmsg *nlmsg);
 define_cleanup_function(struct nlmsg *, nlmsg_free);
 
 /*
@@ -241,9 +242,9 @@ define_cleanup_function(struct nlmsg *, nlmsg_free);
  *
  * Returns a pointer to the netlink data or NULL if there is no data
  */
-void *nlmsg_data(struct nlmsg *nlmsg);
+__hidden extern void *nlmsg_data(struct nlmsg *nlmsg);
 
-extern int addattr(struct nlmsghdr *n, size_t maxlen, int type,
-                  const void *data, size_t alen);
+__hidden extern int addattr(struct nlmsghdr *n, size_t maxlen, int type,
+                           const void *data, size_t alen);
 
 #endif
index 0712594d10cd39c91585914d61fd915bca64026b..cea7336c12ccb79c2b1ecec834cc308a24d8243e 100644 (file)
 #include "nl.h"
 #include "rtnl.h"
 
-extern int rtnetlink_open(struct rtnl_handler *handler)
+int rtnetlink_open(struct rtnl_handler *handler)
 {
        return netlink_open(&handler->nlh, NETLINK_ROUTE);
 }
 
-extern void rtnetlink_close(struct rtnl_handler *handler)
+void rtnetlink_close(struct rtnl_handler *handler)
 {
        netlink_close(&handler->nlh);
 }
@@ -29,20 +29,19 @@ extern void rtnetlink_close(struct rtnl_handler *handler)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-align"
 
-extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
+int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
 {
        return netlink_rcv(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
 }
 
-extern int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
+int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
 {
 
        return netlink_send(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
 }
 
-extern int rtnetlink_transaction(struct rtnl_handler *handler,
-                                struct rtnlmsg *request,
-                                struct rtnlmsg *answer)
+int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
+                         struct rtnlmsg *answer)
 {
        return netlink_transaction(&handler->nlh,
                                   (struct nlmsg *)&request->nlmsghdr,
@@ -51,7 +50,7 @@ extern int rtnetlink_transaction(struct rtnl_handler *handler,
 
 #pragma GCC diagnostic pop
 
-extern struct rtnlmsg *rtnlmsg_alloc(size_t size)
+struct rtnlmsg *rtnlmsg_alloc(size_t size)
 {
        /*
        size_t len;
@@ -63,4 +62,4 @@ extern struct rtnlmsg *rtnlmsg_alloc(size_t size)
        return NULL;
 }
 
-extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); }
+void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); }
index 66ce6bdd5cb59165c00c4a134a698f5ce53b8671..bfe66db0507e2338934ea470d782d2796157db89 100644 (file)
@@ -3,6 +3,8 @@
 #ifndef __LXC_RTNL_H
 #define __LXC_RTNL_H
 
+#include <compiler.h>
+
 /*
  * Use this as a good size to allocate route netlink messages
  */
@@ -38,14 +40,14 @@ struct rtnlmsg {
  *
  * Returns 0 on success, < 0 otherwise
  */
-extern int rtnetlink_open(struct rtnl_handler *handler);
+__hidden extern int rtnetlink_open(struct rtnl_handler *handler);
 
 /*
  * genetlink_close : close a route netlink socket
  *
  * @handler: the handler of the socket to be closed
  */
-extern void rtnetlink_close(struct rtnl_handler *handler);
+__hidden extern void rtnetlink_close(struct rtnl_handler *handler);
 
 /*
  * rtnetlink_rcv : receive a route netlink socket, it is up
@@ -56,7 +58,7 @@ extern void rtnetlink_close(struct rtnl_handler *handler);
  *
  * Returns 0 on success, < 0 otherwise
  */
-extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
+__hidden extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
 
 /*
  * rtnetlink_send : send a route netlink socket, it is up
@@ -67,12 +69,11 @@ extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
  *
  * Returns 0 on success, < 0 otherwise
  */
-extern int rtnetlink_send(struct rtnl_handler *handler,
-                         struct rtnlmsg *rtnlmsg);
+__hidden extern int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
 
-struct genlmsg *genlmsg_alloc(size_t size);
+__hidden struct genlmsg *genlmsg_alloc(size_t size);
 
-extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
+__hidden extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
 
 /*
  * rtnetlink_transaction : send and receive a route netlink message in one shot
@@ -83,8 +84,9 @@ extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
  *
  * Returns 0 on success, < 0 otherwise
  */
-extern int rtnetlink_transaction(struct rtnl_handler *handler,
-                                struct rtnlmsg *request,
-                                struct rtnlmsg *answer);
+__hidden extern int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
+                                         struct rtnlmsg *answer);
+
+__hidden struct rtnlmsg *rtnlmsg_alloc(size_t size);
 
 #endif /* __LXC_RTNL_H */