coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
518 stars 260 forks source link

Runtime errors on Pi 3b running CentOS 7.2 - SOLVED #261

Open mhmeadows63 opened 8 years ago

mhmeadows63 commented 8 years ago

Pi 3b image: CentOS-Userland-7-armv7hl-Minimal-1603-RaspberryPi3

Built Ok, but encountered two runtime errors:

  1. "You need to install haserl to serve pages with this wwwsh script!"
  2. Invalid argument: net_write_eth(fd=2, len=42) failed     kernel: chilli: packet size is too short (42 <= 50)

problem.1 - 'which' is not available in default bash solution.1 - replace 'which' with 'type -p' in wwwsh

diff --git a/www/wwwsh b/www/wwwsh
index 0284f74..fc9296b 100755
--- a/www/wwwsh
+++ b/www/wwwsh
@@ -6,7 +6,7 @@

 file=$(basename $1)
 dir=$(dirname $1)
-haserl=$(which haserl 2>/dev/null)
+haserl=$(type -p haserl 2>/dev/null)
 cd $dir

 # should be make a bit safer!

problem.2 - centos appears to consider an ethernet frame-size of less than 51 as a Runt Frame solution.2 - force a minimum frame size for dhcp_sendGARP() and dhcp_sendARP()

diff --git a/src/dhcp.c b/src/dhcp.c
index 3b56312..00c5357 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -342,7 +342,9 @@ dhcp_sendGARP(struct dhcp_t *this, int idx) {
   memcpy(packet_ethh->src, dhcp_nexthop(this), PKT_ETH_ALEN);
   packet_ethh->prot = htons(PKT_ETH_PROTO_ARP);

-  return dhcp_send(this, idx, bmac, packet, sizeofarp(packet));
+  /* IEEE 802.3 standard defines the minimum Ethernet frame size as 64 bytes */
+  return dhcp_send(this, idx, bmac,
+                  packet, sizeofarp(packet) > 64 ? sizeofarp(packet) : 64);
 }

 void dhcp_authorize_mac(struct dhcp_t *this, uint8_t *hwaddr,
@@ -5835,8 +5837,9 @@ int dhcp_sendARP(struct dhcp_conn_t *conn, uint8_t *pack, size_t len) {
   memcpy(packet_ethh->src, dhcp_nexthop(this), PKT_ETH_ALEN);

   OTHER_SENDING_LEN(conn,sizeof(struct arp_packet_t));
+  /* IEEE 802.3 standard defines the minimum Ethernet frame size as 64 bytes */
   return dhcp_send(this, dhcp_conn_idx(conn), conn->hismac,
-                  packet, sizeofarp(packet));
+                  packet, sizeofarp(packet) > 64 ? sizeofarp(packet) : 64);
 }

This may help someone else.

muratbeser commented 8 years ago

@sevan can we apply this to current branch ? or may be wiki ?

sevan commented 8 years ago

Sure, it would be better if the patches were applied to a local branch and a pull request submitted. At least that way there would be a basic build test against 2 different toolchains (gcc & clang) before we pursued further. As-is I'd have to extract the changes from here & get things in to place for testing.