Make room for multi-type values in struct tentry.
This commit is contained in:
parent
c21034b744
commit
4bbd15771b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/ipfw/; revision=270021
@ -1387,15 +1387,15 @@ tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *arg,
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Try to interpret as number first */
|
/* Try to interpret as number first */
|
||||||
tent->value = strtoul(arg, &p, 0);
|
tent->v.value = strtoul(arg, &p, 0);
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
return;
|
return;
|
||||||
if (inet_pton(AF_INET, arg, &val) == 1) {
|
if (inet_pton(AF_INET, arg, &val) == 1) {
|
||||||
tent->value = ntohl(val);
|
tent->v.value = ntohl(val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Try hostname */
|
/* Try hostname */
|
||||||
if (lookup_host(arg, (struct in_addr *)&tent->value) == 0)
|
if (lookup_host(arg, (struct in_addr *)&tent->v.value) == 0)
|
||||||
return;
|
return;
|
||||||
errx(EX_OSERR, "Unable to parse value %s", arg);
|
errx(EX_OSERR, "Unable to parse value %s", arg);
|
||||||
#if 0
|
#if 0
|
||||||
@ -1565,7 +1565,7 @@ table_show_entry(ipfw_xtable_info *i, ipfw_obj_tentry *tent)
|
|||||||
uint32_t tval;
|
uint32_t tval;
|
||||||
struct tflow_entry *tfe;
|
struct tflow_entry *tfe;
|
||||||
|
|
||||||
tval = tent->value;
|
tval = tent->v.value;
|
||||||
|
|
||||||
if (co.do_value_as_ip || i->vftype == IPFW_VFTYPE_IP) {
|
if (co.do_value_as_ip || i->vftype == IPFW_VFTYPE_IP) {
|
||||||
tval = htonl(tval);
|
tval = htonl(tval);
|
||||||
|
@ -756,12 +756,10 @@ typedef struct _ipfw_obj_tentry {
|
|||||||
ipfw_obj_tlv head; /* TLV header */
|
ipfw_obj_tlv head; /* TLV header */
|
||||||
uint8_t subtype; /* subtype (IPv4,IPv6) */
|
uint8_t subtype; /* subtype (IPv4,IPv6) */
|
||||||
uint8_t masklen; /* mask length */
|
uint8_t masklen; /* mask length */
|
||||||
uint16_t idx; /* Table name index */
|
|
||||||
uint32_t value; /* value */
|
|
||||||
uint8_t result; /* request result */
|
uint8_t result; /* request result */
|
||||||
uint8_t spare0;
|
uint8_t spare0;
|
||||||
|
uint16_t idx; /* Table name index */
|
||||||
uint16_t spare1;
|
uint16_t spare1;
|
||||||
uint32_t spare2;
|
|
||||||
union {
|
union {
|
||||||
/* Longest field needs to be aligned by 8-byte boundary */
|
/* Longest field needs to be aligned by 8-byte boundary */
|
||||||
struct in_addr addr; /* IPv4 address */
|
struct in_addr addr; /* IPv4 address */
|
||||||
@ -770,6 +768,10 @@ typedef struct _ipfw_obj_tentry {
|
|||||||
char iface[IF_NAMESIZE]; /* interface name */
|
char iface[IF_NAMESIZE]; /* interface name */
|
||||||
struct tflow_entry flow;
|
struct tflow_entry flow;
|
||||||
} k;
|
} k;
|
||||||
|
union {
|
||||||
|
uint32_t value; /* 32-bit value */
|
||||||
|
char storage[64]; /* Future needs */
|
||||||
|
} v;
|
||||||
} ipfw_obj_tentry;
|
} ipfw_obj_tentry;
|
||||||
#define IPFW_TF_UPDATE 0x01 /* Update record if exists */
|
#define IPFW_TF_UPDATE 0x01 /* Update record if exists */
|
||||||
/* Container TLV */
|
/* Container TLV */
|
||||||
|
@ -888,7 +888,7 @@ ipfw_manage_table_ent_v1(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
|
|||||||
ptei->masklen = ptent->masklen;
|
ptei->masklen = ptent->masklen;
|
||||||
if (ptent->head.flags & IPFW_TF_UPDATE)
|
if (ptent->head.flags & IPFW_TF_UPDATE)
|
||||||
ptei->flags |= TEI_FLAGS_UPDATE;
|
ptei->flags |= TEI_FLAGS_UPDATE;
|
||||||
ptei->value = ptent->value;
|
ptei->value = ptent->v.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = (oh->opheader.opcode == IP_FW_TABLE_XADD) ?
|
error = (oh->opheader.opcode == IP_FW_TABLE_XADD) ?
|
||||||
@ -2244,7 +2244,7 @@ dump_table_entry(void *e, void *arg)
|
|||||||
|
|
||||||
ent->addr = da->tent.k.addr.s_addr;
|
ent->addr = da->tent.k.addr.s_addr;
|
||||||
ent->masklen = da->tent.masklen;
|
ent->masklen = da->tent.masklen;
|
||||||
ent->value = da->tent.value;
|
ent->value = da->tent.v.value;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -2345,7 +2345,7 @@ dump_table_xentry(void *e, void *arg)
|
|||||||
|
|
||||||
/* Convert current format to previous one */
|
/* Convert current format to previous one */
|
||||||
xent->masklen = tent->masklen;
|
xent->masklen = tent->masklen;
|
||||||
xent->value = tent->value;
|
xent->value = tent->v.value;
|
||||||
/* Apply some hacks */
|
/* Apply some hacks */
|
||||||
if (tc->no.type == IPFW_TABLE_ADDR && tent->subtype == AF_INET) {
|
if (tc->no.type == IPFW_TABLE_ADDR && tent->subtype == AF_INET) {
|
||||||
xent->k.addr6.s6_addr32[3] = tent->k.addr.s_addr;
|
xent->k.addr6.s6_addr32[3] = tent->k.addr.s_addr;
|
||||||
|
@ -482,14 +482,14 @@ ta_dump_radix_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
tent->k.addr.s_addr = n->addr.sin_addr.s_addr;
|
tent->k.addr.s_addr = n->addr.sin_addr.s_addr;
|
||||||
tent->masklen = n->masklen;
|
tent->masklen = n->masklen;
|
||||||
tent->subtype = AF_INET;
|
tent->subtype = AF_INET;
|
||||||
tent->value = n->value;
|
tent->v.value = n->value;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
} else {
|
} else {
|
||||||
xn = (struct radix_addr_xentry *)e;
|
xn = (struct radix_addr_xentry *)e;
|
||||||
memcpy(&tent->k, &xn->addr6.sin6_addr, sizeof(struct in6_addr));
|
memcpy(&tent->k, &xn->addr6.sin6_addr, sizeof(struct in6_addr));
|
||||||
tent->masklen = xn->masklen;
|
tent->masklen = xn->masklen;
|
||||||
tent->subtype = AF_INET6;
|
tent->subtype = AF_INET6;
|
||||||
tent->value = xn->value;
|
tent->v.value = xn->value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,13 +1257,13 @@ ta_dump_chash_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
tent->k.addr.s_addr = htonl(ent->a.a4 << (32 - cfg->mask4));
|
tent->k.addr.s_addr = htonl(ent->a.a4 << (32 - cfg->mask4));
|
||||||
tent->masklen = cfg->mask4;
|
tent->masklen = cfg->mask4;
|
||||||
tent->subtype = AF_INET;
|
tent->subtype = AF_INET;
|
||||||
tent->value = ent->value;
|
tent->v.value = ent->value;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
} else {
|
} else {
|
||||||
memcpy(&tent->k, &ent->a.a6, sizeof(struct in6_addr));
|
memcpy(&tent->k, &ent->a.a6, sizeof(struct in6_addr));
|
||||||
tent->masklen = cfg->mask6;
|
tent->masklen = cfg->mask6;
|
||||||
tent->subtype = AF_INET6;
|
tent->subtype = AF_INET6;
|
||||||
tent->value = ent->value;
|
tent->v.value = ent->value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2354,7 +2354,7 @@ ta_dump_ifidx_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
|
|
||||||
tent->masklen = 8 * IF_NAMESIZE;
|
tent->masklen = 8 * IF_NAMESIZE;
|
||||||
memcpy(&tent->k, ife->no.name, IF_NAMESIZE);
|
memcpy(&tent->k, ife->no.name, IF_NAMESIZE);
|
||||||
tent->value = ife->value;
|
tent->v.value = ife->value;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -2778,7 +2778,7 @@ ta_dump_numarray_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
na = (struct numarray *)e;
|
na = (struct numarray *)e;
|
||||||
|
|
||||||
tent->k.key = na->number;
|
tent->k.key = na->number;
|
||||||
tent->value = na->value;
|
tent->v.value = na->value;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -3124,7 +3124,7 @@ ta_dump_fhash_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
tfe->proto = ent->proto;
|
tfe->proto = ent->proto;
|
||||||
tfe->dport = htons(ent->dport);
|
tfe->dport = htons(ent->dport);
|
||||||
tfe->sport = htons(ent->sport);
|
tfe->sport = htons(ent->sport);
|
||||||
tent->value = ent->value;
|
tent->v.value = ent->value;
|
||||||
tent->subtype = ent->af;
|
tent->subtype = ent->af;
|
||||||
|
|
||||||
if (ent->af == AF_INET) {
|
if (ent->af == AF_INET) {
|
||||||
@ -3693,7 +3693,7 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
len = 0;
|
len = 0;
|
||||||
tent->masklen = len;
|
tent->masklen = len;
|
||||||
tent->subtype = AF_INET;
|
tent->subtype = AF_INET;
|
||||||
tent->value = 0; /* Do we need to put GW here? */
|
tent->v.value = 0; /* Do we need to put GW here? */
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
} else if (addr->sin_family == AF_INET6) {
|
} else if (addr->sin_family == AF_INET6) {
|
||||||
addr6 = (struct sockaddr_in6 *)addr;
|
addr6 = (struct sockaddr_in6 *)addr;
|
||||||
@ -3706,7 +3706,7 @@ ta_dump_kfib_tentry(void *ta_state, struct table_info *ti, void *e,
|
|||||||
len = 0;
|
len = 0;
|
||||||
tent->masklen = len;
|
tent->masklen = len;
|
||||||
tent->subtype = AF_INET6;
|
tent->subtype = AF_INET6;
|
||||||
tent->value = 0;
|
tent->v.value = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user