Use a simpler arrangement for the all_addr union to avoid

the compiler padding it with an extra 8 bytes.

Use the F_KEYTAG flag in a a cache record to discriminate between
an arbitrary RR stored entirely in the addr union and one
which has a point to block storage.
This commit is contained in:
Simon Kelley
2023-04-01 21:35:26 +01:00
parent 3a601d06bd
commit a78487a4df
3 changed files with 84 additions and 51 deletions

View File

@@ -329,21 +329,23 @@ union all_addr {
unsigned short keytag, algo, digest, rcode;
int ede;
} log;
/* for arbitrary RR record. */
/* for arbitrary RR record stored in block */
struct {
#define RR_IMDATALEN 13 /* 16 - sizeof(short) - sizeof (char) */
unsigned short rrtype;
char len; /* -1 for blockdata */
union {
char data[RR_IMDATALEN];
struct {
unsigned short datalen;
struct blockdata *rrdata;
} block;
} u;
} rr;
unsigned short datalen;
struct blockdata *rrdata;
} rrblock;
/* for arbitrary RR record small enough to go in addr.
NOTE: rrblock and rrdata are discriminated by the F_KEYTAG bit
in the cache flags. */
struct datablock {
unsigned short rrtype;
unsigned char datalen;
char data[];
} rrdata;
};
#define RR_IMDATALEN (sizeof(union all_addr) - offsetof(struct datablock, data))
struct bogus_addr {
int is6, prefix;