diff options
author | Martin Schwenke <martin@meltin.net> | 2018-08-14 11:25:02 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2018-08-30 04:48:57 +0200 |
commit | e2a00feca3565d3071424246bb25ad1623bdfe6c (patch) | |
tree | 6f215eeff1018fffc2ea7d0d4e764e281091b727 /ctdb/common | |
parent | 87088af6e49e9ce973cfe77d36cfbf42f9101854 (diff) | |
download | samba-e2a00feca3565d3071424246bb25ad1623bdfe6c.tar.gz |
ctdb-common: Be more careful with packet sizes
Ethernet packets must be at least 64 bytes.
For ARP the packet size was limited to 64 bytes. This is probably OK
but the code might as well be a little more general.
For IPv6 NA there was no guarantee that the packet is at least 64
bytes.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/common')
-rw-r--r-- | ctdb/common/system_socket.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c index ab7f6be5d71..c60243e9801 100644 --- a/ctdb/common/system_socket.c +++ b/ctdb/common/system_socket.c @@ -175,14 +175,19 @@ static uint16_t ip6_checksum(uint16_t *data, size_t n, struct ip6_hdr *ip6) * packets */ -#define ARP_BUFFER_SIZE 64 +#define ARP_STRUCT_SIZE sizeof(struct ether_header) + \ + sizeof(struct ether_arp) -#define IP6_NA_BUFFER_SIZE sizeof(struct ether_header) + \ +#define IP6_NA_STRUCT_SIZE sizeof(struct ether_header) + \ sizeof(struct ip6_hdr) + \ sizeof(struct nd_neighbor_advert) + \ sizeof(struct nd_opt_hdr) + \ sizeof(struct ether_addr) +#define ARP_BUFFER_SIZE MAX(ARP_STRUCT_SIZE, 64) + +#define IP6_NA_BUFFER_SIZE MAX(IP6_NA_STRUCT_SIZE, 64) + static int arp_build(uint8_t *buffer, size_t buflen, const struct sockaddr_in *addr, |