From 9943ed2597a1589d39c9789f1ff16d86a5b75970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 21 Jan 2020 23:47:42 -0800 Subject: [PATCH] add nodad argument to ifc_act_on_address() and add it to header file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: atest Signed-off-by: Maciej Żenczykowski Change-Id: Ia45f00ecc5eae035ed2e25d5b73008acb77fa6c2 --- libnetutils/ifc_utils.c | 9 +++++---- libnetutils/include/netutils/ifc.h | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index 8212eba29..5999e39ba 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c @@ -257,8 +257,8 @@ int ifc_set_addr(const char *name, in_addr_t addr) * * Returns zero on success and negative errno on failure. */ -int ifc_act_on_address(int action, const char *name, const char *address, - int prefixlen) { +int ifc_act_on_address(int action, const char* name, const char* address, int prefixlen, + bool nodad) { int ifindex, s, len, ret; struct sockaddr_storage ss; int saved_errno; @@ -311,6 +311,7 @@ int ifc_act_on_address(int action, const char *name, const char *address, // Interface address message header. req.r.ifa_family = ss.ss_family; + req.r.ifa_flags = nodad ? IFA_F_NODAD : 0; req.r.ifa_prefixlen = prefixlen; req.r.ifa_index = ifindex; @@ -363,12 +364,12 @@ int ifc_act_on_address(int action, const char *name, const char *address, // Returns zero on success and negative errno on failure. int ifc_add_address(const char *name, const char *address, int prefixlen) { - return ifc_act_on_address(RTM_NEWADDR, name, address, prefixlen); + return ifc_act_on_address(RTM_NEWADDR, name, address, prefixlen, /*nodad*/ false); } // Returns zero on success and negative errno on failure. int ifc_del_address(const char *name, const char * address, int prefixlen) { - return ifc_act_on_address(RTM_DELADDR, name, address, prefixlen); + return ifc_act_on_address(RTM_DELADDR, name, address, prefixlen, /*nodad*/ false); } /* diff --git a/libnetutils/include/netutils/ifc.h b/libnetutils/include/netutils/ifc.h index 3b272343d..ee896ac08 100644 --- a/libnetutils/include/netutils/ifc.h +++ b/libnetutils/include/netutils/ifc.h @@ -17,8 +17,9 @@ #ifndef _NETUTILS_IFC_H_ #define _NETUTILS_IFC_H_ -#include #include +#include +#include __BEGIN_DECLS @@ -42,6 +43,8 @@ extern int ifc_reset_connections(const char *ifname, const int reset_mask); extern int ifc_get_addr(const char *name, in_addr_t *addr); extern int ifc_set_addr(const char *name, in_addr_t addr); +extern int ifc_act_on_address(int action, const char* name, const char* address, int prefixlen, + bool nodad); extern int ifc_add_address(const char *name, const char *address, int prefixlen); extern int ifc_del_address(const char *name, const char *address,