Re: Build dhcpcd with error ‘IFA_FLAGS’ undeclared
Roy Marples
Thu Aug 01 08:56:22 2019
Hi Roman
On 01/08/2019 08:34, urv wrote:
Hello, Roy!
Build dhcpcd v.8.0 and newer on quite old kernel 3.10 finish with error:
if-linux.c: In function ‘if_address’:
if-linux.c:1511:38: error: ‘IFA_FLAGS’ undeclared (first use in this
function)
add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
^~~~~~~~~
if-linux.c:1511:38: note: each undeclared identifier is reported only
once for each function it appears in
if-linux.c: In function ‘if_address6’:
if-linux.c:1585:38: error: ‘IFA_FLAGS’ undeclared (first use in this
function)
add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
^~~~~~~~~
Problem appear with commit "d1468fbdad0e288b23c9e5181d1de4476691ae61"
And yes, header file "linux/if_addr.h" doesn't have declaration of
'IFA_FLAGS'
What I want for Christmas is for linux headers to use #defines.
Sadly this patch will have to do. Does it fix your compile issue?
Roy
diff --git a/src/if-linux.c b/src/if-linux.c
index 3919bff5..b7e84eb5 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -1480,7 +1480,9 @@ if_address(unsigned char cmd, const struct ipv4_addr *ia)
struct nlma nlm;
struct ifa_cacheinfo cinfo;
int retval = 0;
+#ifdef IFA_F_NOPREFIXROUTE
uint32_t flags = 0;
+#endif
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
@@ -1507,8 +1509,8 @@ if_address(unsigned char cmd, const struct ipv4_addr *ia)
#ifdef IFA_F_NOPREFIXROUTE
if (nlm.ifa.ifa_prefixlen < 32)
flags |= IFA_F_NOPREFIXROUTE;
-#endif
add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
+#endif
add_attr_l(&nlm.hdr, sizeof(nlm), IFA_BROADCAST,
&ia->brd.s_addr, sizeof(ia->brd.s_addr));
@@ -1542,7 +1544,9 @@ if_address6(unsigned char cmd, const struct ipv6_addr *ia)
{
struct nlma nlm;
struct ifa_cacheinfo cinfo;
+#if defined(IFA_F_MANAGETEMPADDR) || defined(IFA_F_NOPREFIXROUTE)
uint32_t flags = 0;
+#endif
memset(&nlm, 0, sizeof(nlm));
nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
@@ -1582,7 +1586,9 @@ if_address6(unsigned char cmd, const struct ipv6_addr *ia)
if (!IN6_IS_ADDR_LINKLOCAL(&ia->addr))
flags |= IFA_F_NOPREFIXROUTE;
#endif
+#if defined(IFA_F_MANAGETEMPADDR) || defined(IFA_F_NOPREFIXROUTE)
add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
+#endif
memset(&cinfo, 0, sizeof(cinfo));
cinfo.ifa_prefered = ia->prefix_pltime;
Archive administrator: postmaster@marples.name