summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2012-09-19 15:13:38 +0000
committerFlorian Fainelli <florian@openwrt.org>2012-09-19 15:13:38 +0000
commit9e504b31a4af9bd106235baf5183f48b5f586b94 (patch)
treea34057c2ad8a09f5275b409224a002d2310f05f1 /package
parent57bd95734dd26a7313d6e9238e4ad5855562d19e (diff)
downloadmtk-20170518-9e504b31a4af9bd106235baf5183f48b5f586b94.zip
mtk-20170518-9e504b31a4af9bd106235baf5183f48b5f586b94.tar.gz
mtk-20170518-9e504b31a4af9bd106235baf5183f48b5f586b94.tar.bz2
busybox: add support for CHECKSUM_PARTIAL to udhcpc
When running as KVM or Xen guest, packets may be received with incomplete checksum[1]. Patch adopted from Fedora dhcp package. [1]. http://article.gmane.org/gmane.linux.kernel/1003853 Signed-off-by: Alexey I. Froloff <raorn@raorn.name> SVN-Revision: 33475
Diffstat (limited to 'package')
-rw-r--r--package/busybox/Makefile2
-rw-r--r--package/busybox/patches/950-partial-checksum.patch87
2 files changed, 88 insertions, 1 deletions
diff --git a/package/busybox/Makefile b/package/busybox/Makefile
index 76f52fc..6352eec 100644
--- a/package/busybox/Makefile
+++ b/package/busybox/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=busybox
PKG_VERSION:=1.19.4
-PKG_RELEASE:=4
+PKG_RELEASE:=5
PKG_FLAGS:=essential
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
diff --git a/package/busybox/patches/950-partial-checksum.patch b/package/busybox/patches/950-partial-checksum.patch
new file mode 100644
index 0000000..e595162
--- /dev/null
+++ b/package/busybox/patches/950-partial-checksum.patch
@@ -0,0 +1,87 @@
+diff -ur busybox-1.19.4.orig/networking/udhcp/dhcpc.c busybox-1.19.4/networking/udhcp/dhcpc.c
+--- busybox-1.19.4.orig/networking/udhcp/dhcpc.c 2012-09-06 22:33:53.476998721 +0400
++++ busybox-1.19.4/networking/udhcp/dhcpc.c 2012-09-07 01:09:46.693372304 +0400
+@@ -26,8 +26,8 @@
+ #include "dhcpc.h"
+
+ #include <netinet/if_ether.h>
+-#include <netpacket/packet.h>
+ #include <linux/filter.h>
++#include <linux/if_packet.h>
+
+ /* struct client_config_t client_config is in bb_common_bufsiz1 */
+
+@@ -784,17 +784,41 @@
+ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
+ {
+ int bytes;
++ int nocsum = 0;
+ struct ip_udp_dhcp_packet packet;
+ uint16_t check;
++ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
++ struct iovec iov = {
++ .iov_base = &packet,
++ .iov_len = sizeof(packet),
++ };
++ struct msghdr msg = {
++ .msg_iov = &iov,
++ .msg_iovlen = 1,
++ .msg_control = cmsgbuf,
++ .msg_controllen = sizeof(cmsgbuf),
++ };
++ struct cmsghdr *cmsg;
+
+ memset(&packet, 0, sizeof(packet));
+- bytes = safe_read(fd, &packet, sizeof(packet));
++ do {
++ bytes = recvmsg(fd, &msg, 0);
++ } while (bytes < 0 && errno == EINTR);
++
+ if (bytes < 0) {
+ log1("Packet read error, ignoring");
+ /* NB: possible down interface, etc. Caller should pause. */
+ return bytes; /* returns -1 */
+ }
+
++ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
++ if (cmsg->cmsg_level == SOL_PACKET &&
++ cmsg->cmsg_type == PACKET_AUXDATA) {
++ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
++ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY;
++ }
++ }
++
+ if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
+ log1("Packet is too short, ignoring");
+ return -2;
+@@ -834,7 +858,7 @@
+ packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
+ check = packet.udp.check;
+ packet.udp.check = 0;
+- if (check && check != udhcp_checksum(&packet, bytes)) {
++ if (!nocsum && check && check != udhcp_checksum(&packet, bytes)) {
+ log1("Packet with bad UDP checksum received, ignoring");
+ return -2;
+ }
+@@ -880,6 +904,7 @@
+ {
+ int fd;
+ struct sockaddr_ll sock;
++ int val;
+
+ /*
+ * Comment:
+@@ -946,6 +971,13 @@
+ log1("Attached filter to raw socket fd %d", fd); // log?
+ }
+
++ val = 1;
++ if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA, &val,
++ sizeof(val)) < 0) {
++ if (errno != ENOPROTOOPT)
++ log1("Failed to set auxiliary packet data for socket fd %d", fd);
++ }
++
+ log1("Created raw socket");
+
+ return fd;