]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Move packet buffer from dhcpcd context to a generic stack variable based on MTU_MAX.
authorRoy Marples <roy@marples.name>
Fri, 6 May 2016 14:46:32 +0000 (14:46 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 May 2016 14:46:32 +0000 (14:46 +0000)
dhcp.c
dhcpcd.h

diff --git a/dhcp.c b/dhcp.c
index 089502f2a69df354910599643b7cbc8eaeb7cc3f..69a030e2459bd769a8ccf3263fe6019627eb9dca 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -3093,7 +3093,7 @@ static void
 dhcp_handlepacket(void *arg)
 {
        struct interface *ifp = arg;
-       uint8_t *bootp;
+       uint8_t *bootp, buf[MTU_MAX];
        size_t bytes;
        struct in_addr from;
        int i, flags;
@@ -3104,7 +3104,7 @@ dhcp_handlepacket(void *arg)
        bootp = NULL;
        while (!(flags & RAW_EOF)) {
                bytes = (size_t)if_readrawpacket(ifp, ETHERTYPE_IP,
-                   ifp->ctx->packet, sizeof(ifp->ctx->packet), &flags);
+                   buf, sizeof(buf), &flags);
                if ((ssize_t)bytes == -1) {
                        logger(ifp->ctx, LOG_ERR,
                            "%s: dhcp if_readrawpacket: %m", ifp->name);
@@ -3112,7 +3112,7 @@ dhcp_handlepacket(void *arg)
                        arp_close(ifp);
                        break;
                }
-               if (valid_udp_packet(ifp->ctx->packet, bytes,
+               if (valid_udp_packet(buf, bytes,
                    &from, flags & RAW_PARTIALCSUM) == -1)
                {
                        logger(ifp->ctx, LOG_ERR,
@@ -3142,7 +3142,7 @@ dhcp_handlepacket(void *arg)
                            ifp->name, inet_ntoa(from));
                }
 
-               bytes = get_udp_data(&bootp, ifp->ctx->packet);
+               bytes = get_udp_data(&bootp, buf);
                if (bytes < sizeof(struct bootp)) {
                        logger(ifp->ctx, LOG_ERR,
                            "%s: truncated packet (%zu) from %s",
index 9047e1c17efac688276a07a4aabdf1f7a6e50f77..a55acfee4be10ba30869d08b17b814082e2ba7e1 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -156,7 +156,6 @@ struct dhcpcd_ctx {
        struct rt_head *ipv4_kroutes;
 
        int udp_fd;
-       uint8_t packet[1500];   /* maximum packet we deal with */
 
        /* Our aggregate option buffer.
         * We ONLY use this when options are split, which for most purposes is