]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Linux Packet Filter interface improvement. sockaddr_pkt structure is used,
authorTomek Mrugalski <tomek@isc.org>
Tue, 10 May 2011 14:27:56 +0000 (14:27 +0000)
committerTomek Mrugalski <tomek@isc.org>
Tue, 10 May 2011 14:27:56 +0000 (14:27 +0000)
rather than sockaddr. Packet ethertype is now forced to ETH_P_IP.
[ISC-Bugs #18975]

RELNOTES
common/lpf.c

index 06a3b77184b196f1d8c78de323c606b49719acb1..6a2dbaa24907796e75af8dbbbd46649a206ea07f 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -120,6 +120,10 @@ work on other platforms. Please report any problems and suggested fixes to
 - Relay now properly logs that packet was received over interface without
   global IPv6 address [ISC-Bugs #24070]
 
+- Linux Packet Filter interface improvement. sockaddr_pkt structure is used, 
+  rather than sockaddr. Packet ethertype is now forced to ETH_P_IP. 
+  [ISC-Bugs #18975]
+
                        Changes since 4.2.0
 
 - Documentation cleanup covering multiple tickets
index f727b7cc5abcad54708e05d434ad7fbbb4dfbc16..16eecc95800280584cad0b0cf0df3b793f82586f 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/filter.h>
 #include <linux/if_ether.h>
 #include <netinet/in_systm.h>
+#include <net/if_packet.h>
 #include "includes/netinet/ip.h"
 #include "includes/netinet/udp.h"
 #include "includes/netinet/if_ether.h"
@@ -294,7 +295,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
        double hh [16];
        double ih [1536 / sizeof (double)];
        unsigned char *buf = (unsigned char *)ih;
-       struct sockaddr sa;
+       struct sockaddr_pkt sa;
        int result;
        int fudge;
 
@@ -318,12 +319,14 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
        /* For some reason, SOCK_PACKET sockets can't be connected,
           so we have to do a sentdo every time. */
        memset (&sa, 0, sizeof sa);
-       sa.sa_family = AF_PACKET;
-       strncpy (sa.sa_data,
-                (const char *)interface -> ifp, sizeof sa.sa_data);
+       sa.spkt_family = AF_PACKET;
+       strncpy ((char *)sa.spkt_device,
+                (const char *)interface -> ifp, sizeof sa.spkt_device);
+       sa.spkt_protocol = htons(ETH_P_IP);
 
        result = sendto (interface -> wfdesc,
-                        buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa);
+                        buf + fudge, ibufp + len - fudge, 0, 
+                        (const struct sockaddr *)&sa, sizeof sa);
        if (result < 0)
                log_error ("send_packet: %m");
        return result;