File klibc-2.0.4-ipconfig.patch of Package klibc

diff -Nurp klibc-2.0.4/usr/kinit/ipconfig/dhcp_proto.c klibc-2.0.4-ipconfig/usr/kinit/ipconfig/dhcp_proto.c
--- klibc-2.0.4/usr/kinit/ipconfig/dhcp_proto.c	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-ipconfig/usr/kinit/ipconfig/dhcp_proto.c	2014-09-22 06:20:36.593286331 +0300
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+#include <net/if_arp.h>
 
 #include "ipconfig.h"
 #include "netdev.h"
@@ -204,7 +205,14 @@ static int dhcp_send(struct netdev *dev,
 	bootp.yiaddr	= dev->ip_addr;
 	bootp.giaddr	= INADDR_ANY;
 	bootp.secs	= htons(time(NULL) - dev->open_time);
-	memcpy(bootp.chaddr, dev->hwaddr, 16);
+	if (dev->hwtype == ARPHRD_INFINIBAND) {
+		bootp.hlen = 0;
+		memset(bootp.chaddr, 0, 16);
+		if (bootp.ciaddr == 0)
+			bootp.flags = htons(0x8000);
+	} else {
+		memcpy(bootp.chaddr, dev->hwaddr, 16);
+	}
 
 	vec[1].iov_base	= &bootp;
 	vec[1].iov_len	= sizeof(struct bootp_hdr);
diff -Nurp klibc-2.0.4/usr/kinit/ipconfig/main.c klibc-2.0.4-ipconfig/usr/kinit/ipconfig/main.c
--- klibc-2.0.4/usr/kinit/ipconfig/main.c	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-ipconfig/usr/kinit/ipconfig/main.c	2014-09-22 06:20:38.754286185 +0300
@@ -14,6 +14,7 @@
 #include <unistd.h>		/* for getopts */
 
 #include <net/if_arp.h>
+#include <asm-generic/errno.h> /* for ETIMEDOUT */
 
 #include "ipconfig.h"
 #include "netdev.h"
@@ -390,9 +391,10 @@ static int loop(void)
 	struct pollfd fds[NR_FDS];
 	struct state *s;
 	int pkt_fd;
-	int nr = 0, rc = 0;
+	int nr = 0;
 	struct timeval now, prev;
 	time_t start;
+	int ret;
 
 	pkt_fd = packet_open();
 	if (pkt_fd == -1) {
@@ -405,7 +407,7 @@ static int loop(void)
 
 	gettimeofday(&now, NULL);
 	start = now.tv_sec;
-	while (1) {
+	for (ret = 0;;) {
 		int timeout = 60;
 		int pending = 0;
 		int done = 0;
@@ -455,7 +457,7 @@ static int loop(void)
 			    now.tv_sec - start >= loop_timeout) {
 				printf("IP-Config: no response after %d "
 				       "secs - giving up\n", loop_timeout);
-				rc = -1;
+				ret = ETIMEDOUT;
 				goto bail;
 			}
 
@@ -470,7 +472,7 @@ static int loop(void)
 bail:
 	packet_close();
 
-	return rc;
+	return ret;
 }
 
 static int add_one_dev(struct netdev *dev)
@@ -785,7 +787,7 @@ int ipconfig_main(int argc, char *argv[]
 {
 	struct netdev *dev;
 	int c, port;
-	int err = 0;
+	int err;
 
 	/* If progname is set we're invoked from another program */
 	if (!progname) {
@@ -863,8 +865,8 @@ int ipconfig_main(int argc, char *argv[]
 			       "dest to %d\n",
 			       cfg_local_port, cfg_remote_port);
 		}
-		err = loop();
+		return loop();
 	}
 
-	return err;
+	return 0;
 }
diff -Nurp klibc-2.0.4/usr/kinit/ipconfig/netdev.c klibc-2.0.4-ipconfig/usr/kinit/ipconfig/netdev.c
--- klibc-2.0.4/usr/kinit/ipconfig/netdev.c	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-ipconfig/usr/kinit/ipconfig/netdev.c	2014-09-22 06:20:42.065285961 +0300
@@ -11,8 +11,7 @@
 #include <net/if.h>
 #include <net/if_arp.h>
 #include <netinet/in.h>
-#include <linux/route.h>
-#include <linux/sockios.h>
+#include <net/route.h>
 
 #include "netdev.h"
 
@@ -220,6 +219,9 @@ int netdev_init_if(struct netdev *dev)
 	case ARPHRD_LOOPBACK:
 		dev->hwlen = 0;
 		break;
+	case ARPHRD_INFINIBAND:
+		dev->hwlen = 20;
+		break;
 	default:
 		return -1;
 	}
diff -Nurp klibc-2.0.4/usr/kinit/ipconfig/netdev.h klibc-2.0.4-ipconfig/usr/kinit/ipconfig/netdev.h
--- klibc-2.0.4/usr/kinit/ipconfig/netdev.h	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-ipconfig/usr/kinit/ipconfig/netdev.h	2014-09-22 06:20:43.406285870 +0300
@@ -7,13 +7,17 @@
 #define BPLEN		256
 #define FNLEN		128			/* from DHCP  RFC 2131 */
 
+#ifndef SYS_NMLN
+#define SYS_NMLN	65
+#endif
+
 struct netdev {
 	const char *name;	/* Device name          */
 	unsigned int ifindex;	/* interface index      */
 	unsigned int hwtype;	/* ARPHRD_xxx           */
 	unsigned int hwlen;	/* HW address length    */
-	uint8_t hwaddr[16];	/* HW address           */
-	uint8_t hwbrd[16];	/* Broadcast HW address */
+	uint8_t hwaddr[20];	/* HW address           */
+	uint8_t hwbrd[20];	/* Broadcast HW address */
 	unsigned int mtu;	/* Device mtu           */
 	unsigned int caps;	/* Capabilities         */
 	time_t open_time;
diff -Nurp klibc-2.0.4/usr/kinit/ipconfig/packet.c klibc-2.0.4-ipconfig/usr/kinit/ipconfig/packet.c
--- klibc-2.0.4/usr/kinit/ipconfig/packet.c	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-ipconfig/usr/kinit/ipconfig/packet.c	2014-09-22 06:20:44.607285789 +0300
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <net/if_packet.h>
 #include <netinet/if_ether.h>
 #include <netinet/in.h>
 #include <netpacket/packet.h>
openSUSE Build Service is sponsored by