Skip to content

Commit

Permalink
ninfod: remove suptypes and ttl code
Browse files Browse the repository at this point in the history
When build system was changed[1] option to turn on suptypes and related ttl
support was accidentally not added to meson.  That is probably, suptypes has
been deprecated ever since the code first appeared[2] in history of iputils.
So the suptypes has not been recommended to use at least for six and half
years, and it is reasonable to remote the code.

Reference [1]: 2f565a5
Reference [2]: c0685f7
Signed-off-by: Sami Kerola <[email protected]>
  • Loading branch information
kerolasa committed Mar 23, 2019
1 parent 9425598 commit a6921f3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 104 deletions.
3 changes: 0 additions & 3 deletions ninfod/icmp6_nodeinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ struct icmp6_nodeinfo {

/* NI Codes */
#define NI_QTYPE_NOOP 0 /* NOOP */
#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
#define NI_QTYPE_DNSNAME 2 /* DNS Name */
#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */

/* NI Flags */
#if WORDS_BIGENDIAN
#define NI_SUPTYPE_FLAG_COMPRESS 0x1
#define NI_FQDN_FLAG_VALIDTTL 0x1
#else
#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
#define NI_FQDN_FLAG_VALIDTTL 0x0100
#endif

Expand Down
4 changes: 0 additions & 4 deletions ninfod/ninfod.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
#define MAX_QUERY_SIZE (sizeof(struct icmp6_nodeinfo)+MAX_DNSNAME_SIZE+2)
#define MAX_REPLY_SIZE 1280-sizeof(struct ip6_hdr)

#define MAX_SUPTYPES 32

#define CHECKANDFILL_ARGS struct packetcontext *p,\
char *subject, size_t subjlen, \
unsigned int flags, \
Expand Down Expand Up @@ -110,8 +108,6 @@ int pr_nodeinfo(struct packetcontext *p);
int pr_nodeinfo_unknown(CHECKANDFILL_ARGS);
int pr_nodeinfo_refused(CHECKANDFILL_ARGS);
int pr_nodeinfo_noop(CHECKANDFILL_ARGS);
void init_nodeinfo_suptypes(INIT_ARGS);
int pr_nodeinfo_suptypes(CHECKANDFILL_ARGS);

/* ninfod_addrs.c */
void init_nodeinfo_ipv6addr(INIT_ARGS __attribute__((__unused__)));
Expand Down
26 changes: 2 additions & 24 deletions ninfod/ninfod_addrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int pr_nodeinfo_ipv6addr(CHECKANDFILL_ARGS)
ifa && addrs < addrs0;
ifa = ifa->ifa_next) {
char *cp;
uint32_t ttl;
const uint32_t ttl = 0;

if (!ifa->ifa_addr)
continue;
Expand All @@ -266,17 +266,6 @@ int pr_nodeinfo_ipv6addr(CHECKANDFILL_ARGS)
if (filter_ipv6addr((struct in6_addr *)ifa->ifa_addr, flags))
continue;

#if ENABLE_TTL
if (ifa->ifa_cacheinfo) {
ttl = ifa->ifa_cacheinfo->ifa_valid > 0x7fffffff ?
htonl(0x7fffffff) : htonl(ifa->ifa_cacheinfo->ifa_valid);
} else {
ttl = (ifa->ifa_flags & IFA_F_PERMANENT) ? htonl(0x7fffffff) : 0;
}
#else
ttl = 0;
#endif

cp = p->replydata +
(sizeof(uint32_t)+sizeof(struct in6_addr)) * (ifa->ifa_flags & IFA_F_DEPRECATED ? paddrs0+daddrs : paddrs);
memcpy(cp, &ttl, sizeof(ttl));
Expand Down Expand Up @@ -406,7 +395,7 @@ int pr_nodeinfo_ipv4addr(CHECKANDFILL_ARGS)
ifa && addrs < addrs0;
ifa = ifa->ifa_next) {
char *cp;
uint32_t ttl;
const uint32_t ttl = 0;

if (!ifa->ifa_addr)
continue;
Expand All @@ -418,17 +407,6 @@ int pr_nodeinfo_ipv4addr(CHECKANDFILL_ARGS)
(ifa->ifa_ifindex != ifindex))
continue;

#if ENABLE_TTL
if (ifa->ifa_cacheinfo) {
ttl = ifa->ifa_cacheinfo->ifa_valid > 0x7fffffff ?
htonl(0x7fffffff) : htonl(ifa->ifa_cacheinfo->ifa_valid);
} else {
ttl = 0; /*XXX*/
}
#else
ttl = 0;
#endif

cp = (p->replydata +
(sizeof(uint32_t)+sizeof(struct in_addr)) * (ifa->ifa_flags & IFA_F_DEPRECATED ? paddrs0+daddrs : paddrs));
memcpy(cp, &ttl, sizeof(ttl));
Expand Down
73 changes: 0 additions & 73 deletions ninfod/ninfod_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,6 @@ static struct qtypeinfo qtypeinfo_table[] = {
.name = "NOOP",
.getreply = pr_nodeinfo_noop,
},
#if ENABLE_SUPTYPES
[NI_QTYPE_SUPTYPES] = {
.qtype = NI_QTYPE_SUPTYPES,
.name = "SupTypes",
.getreply = pr_nodeinfo_suptypes,
.init = init_nodeinfo_suptypes,
},
#endif
[NI_QTYPE_DNSNAME] = {
.qtype = NI_QTYPE_DNSNAME,
.name = "DnsName",
Expand Down Expand Up @@ -250,70 +242,6 @@ int pr_nodeinfo_noop(CHECKANDFILL_ARGS_3)
return 0;
}

#if ENABLE_SUPTYPES
/* suptypes */
int pr_nodeinfo_suptypes(CHECKANDFILL_ARGS)
{
DEBUG(LOG_DEBUG, "%s()\n", __func__);

if (subjlen) {
DEBUG(LOG_WARNING, "%s(): invalid subject length(%zu)\n",
__func__, subjlen);
return 1;
}

if (reply) {
p->reply.ni_type = ICMP6_NI_REPLY;
p->reply.ni_code = ICMP6_NI_SUCCESS;
p->reply.ni_cksum = 0;
p->reply.ni_qtype = htons(NI_QTYPE_SUPTYPES);
p->reply.ni_flags = flags&~NI_SUPTYPE_FLAG_COMPRESS;

p->replydatalen = suptypes_len<<2;
p->replydata = malloc(p->replydatalen);
if (p->replydata == NULL) {
p->replydatalen = -1;
return -1; /*XXX*/
}

memcpy(p->replydata, suptypes, p->replydatalen);
}
return 0;
}

void init_nodeinfo_suptypes(INIT_ARGS)
{
size_t w, b;
int i;

if (!forced && initialized)
return;

memset(suptypes, 0, sizeof(suptypes));
suptypes_len = 0;

for (i=0; i < ARRAY_SIZE(qtypeinfo_table); i++) {
unsigned short qtype;

if (qtypeinfo_table[i].name == NULL)
continue;
qtype = qtypeinfo_table[i].qtype;
w = qtype>>5;
b = qtype&0x1f;
if (w >= ARRAY_SIZE(suptypes)) {
/* This is programming error. */
DEBUG(LOG_ERR, "Warning: Too Large Supported Types\n");
exit(1);
}
suptypes[w] |= htonl(1<<b);

if (suptypes_len < w)
suptypes_len = w;
}
suptypes_len++;
}
#endif

/* ---------- */
/* unknown qtype response */
int pr_nodeinfo_unknown(CHECKANDFILL_ARGS_1)
Expand Down Expand Up @@ -551,7 +479,6 @@ int pr_nodeinfo(struct packetcontext *p)
/* Step 2: Check Subject Code */
switch(htons(query->ni_qtype)) {
case NI_QTYPE_NOOP:
case NI_QTYPE_SUPTYPES:
if (query->ni_code != ICMP6_NI_SUBJ_FQDN) {
DEBUG(LOG_WARNING,
"%s(): invalid/unknown code %u\n",
Expand Down

0 comments on commit a6921f3

Please sign in to comment.