From d0d787e797aaadf010bc360a8fc84d0886449085 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Feb 26 2015 09:30:55 +0000 Subject: correctly set IB's hw->hlen (#1185075) --- diff --git a/dhcp-IPoIB-log-id.patch b/dhcp-IPoIB-log-id.patch index 407d50f..68b4e00 100644 --- a/dhcp-IPoIB-log-id.patch +++ b/dhcp-IPoIB-log-id.patch @@ -1,101 +1,6 @@ diff -up dhcp-4.3.2b1/common/lpf.c.IPoIB-log-id dhcp-4.3.2b1/common/lpf.c --- dhcp-4.3.2b1/common/lpf.c.IPoIB-log-id 2015-02-08 17:37:47.055023959 +0100 +++ dhcp-4.3.2b1/common/lpf.c 2015-02-08 17:41:21.294972666 +0100 -@@ -152,6 +152,8 @@ int if_register_lpf (info) - void if_register_send (info) - struct interface_info *info; - { -+ int hlen; -+ - /* If we're using the lpf API for sending and receiving, - we don't need to register this interface twice. */ - #ifndef USE_LPF_RECEIVE -@@ -159,11 +161,15 @@ void if_register_send (info) - #else - info -> wfdesc = info -> rfdesc; - #endif -+ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) -+ hlen = 9; -+ else -+ hlen = info -> hw_address.hlen; - if (!quiet_interface_discovery) - log_info ("Sending on LPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], -- info -> hw_address.hlen - 1, -+ hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? -@@ -173,6 +179,10 @@ void if_register_send (info) - void if_deregister_send (info) - struct interface_info *info; - { -+ int hlen = info -> hw_address.hlen; -+ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) -+ hlen = 9; -+ - /* don't need to close twice if we are using lpf for sending and - receiving */ - #ifndef USE_LPF_RECEIVE -@@ -185,7 +195,7 @@ void if_deregister_send (info) - log_info ("Disabling output on LPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], -- info -> hw_address.hlen - 1, -+ hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? -@@ -212,6 +222,8 @@ static void lpf_gen_filter_setup (struct - void if_register_receive (info) - struct interface_info *info; - { -+ int hlen; -+ - /* Open a LPF device and hang it on this interface... */ - info -> rfdesc = if_register_lpf (info); - -@@ -225,7 +237,9 @@ void if_register_receive (info) - log_fatal ("Failed to set auxiliary packet data: %m"); - } - } -- } -+ hlen = info -> hw_address.hlen; -+ } else -+ hlen = 9; - } - #endif - -@@ -241,7 +255,7 @@ void if_register_receive (info) - log_info ("Listening on LPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], -- info -> hw_address.hlen - 1, -+ hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? -@@ -251,6 +265,10 @@ void if_register_receive (info) - void if_deregister_receive (info) - struct interface_info *info; - { -+ int hlen = info -> hw_address.hlen; -+ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) -+ hlen = 9; -+ - /* for LPF this is simple, packet filters are removed when sockets - are closed */ - close (info -> rfdesc); -@@ -259,7 +277,7 @@ void if_deregister_receive (info) - log_info ("Disabling input on LPF/%s/%s%s%s", - info -> name, - print_hw_addr (info -> hw_address.hbuf [0], -- info -> hw_address.hlen - 1, -+ hlen - 1, - &info -> hw_address.hbuf [1]), - (info -> shared_network ? "/" : ""), - (info -> shared_network ? diff -up dhcp-4.3.2b1/server/dhcp.c.IPoIB-log-id dhcp-4.3.2b1/server/dhcp.c --- dhcp-4.3.2b1/server/dhcp.c.IPoIB-log-id 2015-02-08 17:37:46.980025024 +0100 +++ dhcp-4.3.2b1/server/dhcp.c 2015-02-08 17:37:47.061023874 +0100 diff --git a/dhcp-duidv4.patch b/dhcp-duidv4.patch index 7b2dfab..52fde3b 100644 --- a/dhcp-duidv4.patch +++ b/dhcp-duidv4.patch @@ -32,47 +32,3 @@ diff -up dhcp-4.3.1b1/client/dhclient.c.KrJcIv dhcp-4.3.1b1/client/dhclient.c } /* Individual States: -@@ -3342,6 +3342,7 @@ form_duid(struct data_string *duid, cons - struct interface_info *ip; - int len; - char *str; -+ unsigned hlen; - - /* For now, just use the first interface on the list. */ - ip = interfaces; -@@ -3365,6 +3366,11 @@ form_duid(struct data_string *duid, cons - if (duid_type == 0) - duid_type = stateless ? DUID_LL : DUID_LLT; - -+ if (ip->hw_address.hbuf[0] == HTYPE_INFINIBAND) -+ hlen = 9; -+ else -+ hlen = ip->hw_address.hlen; -+ - /* - * 2 bytes for the 'duid type' field. - * 2 bytes for the 'htype' field. -@@ -3372,7 +3378,7 @@ form_duid(struct data_string *duid, cons - * enough bytes for the hardware address (note that hw_address has - * the 'htype' on byte zero). - */ -- len = 4 + (ip->hw_address.hlen - 1); -+ len = 4 + (hlen - 1); - if (duid_type == DUID_LLT) - len += 4; - if (!buffer_allocate(&duid->buffer, len, MDL)) -@@ -3386,12 +3392,12 @@ form_duid(struct data_string *duid, cons - putUShort(duid->buffer->data + 2, ip->hw_address.hbuf[0]); - putULong(duid->buffer->data + 4, cur_time - DUID_TIME_EPOCH); - memcpy(duid->buffer->data + 8, ip->hw_address.hbuf + 1, -- ip->hw_address.hlen - 1); -+ hlen - 1); - } else { - putUShort(duid->buffer->data, DUID_LL); - putUShort(duid->buffer->data + 2, ip->hw_address.hbuf[0]); - memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1, -- ip->hw_address.hlen - 1); -+ hlen - 1); - } - - str = quotify_buf(duid->data, duid->len, MDL); diff --git a/dhcp-lpf-ib.patch b/dhcp-lpf-ib.patch index b5487e0..4955dcf 100644 --- a/dhcp-lpf-ib.patch +++ b/dhcp-lpf-ib.patch @@ -1,6 +1,6 @@ diff -up dhcp-4.3.2b1/client/dhclient.c.lpf-ib dhcp-4.3.2b1/client/dhclient.c ---- dhcp-4.3.2b1/client/dhclient.c.lpf-ib 2015-02-08 17:19:42.107405843 +0100 -+++ dhcp-4.3.2b1/client/dhclient.c 2015-02-08 17:19:42.116405716 +0100 +--- dhcp-4.3.2b1/client/dhclient.c.lpf-ib 2015-02-26 09:49:40.553785504 +0100 ++++ dhcp-4.3.2b1/client/dhclient.c 2015-02-26 09:49:40.561785398 +0100 @@ -114,6 +114,8 @@ static int check_domain_name_list(const static int check_option_values(struct universe *universe, unsigned int opt, const char *ptr, size_t len); @@ -55,8 +55,8 @@ diff -up dhcp-4.3.2b1/client/dhclient.c.lpf-ib dhcp-4.3.2b1/client/dhclient.c * * Each routine is called from the dhclient_state_machine() in one of diff -up dhcp-4.3.2b1/common/bpf.c.lpf-ib dhcp-4.3.2b1/common/bpf.c ---- dhcp-4.3.2b1/common/bpf.c.lpf-ib 2015-02-08 17:19:42.101405928 +0100 -+++ dhcp-4.3.2b1/common/bpf.c 2015-02-08 17:19:42.116405716 +0100 +--- dhcp-4.3.2b1/common/bpf.c.lpf-ib 2015-02-26 09:49:40.546785596 +0100 ++++ dhcp-4.3.2b1/common/bpf.c 2015-02-26 09:49:40.561785398 +0100 @@ -199,11 +199,44 @@ struct bpf_insn dhcp_bpf_filter [] = { BPF_STMT(BPF_RET+BPF_K, 0), }; @@ -103,8 +103,8 @@ diff -up dhcp-4.3.2b1/common/bpf.c.lpf-ib dhcp-4.3.2b1/common/bpf.c struct bpf_insn dhcp_bpf_tr_filter [] = { /* accept all token ring packets due to variable length header */ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c ---- dhcp-4.3.2b1/common/lpf.c.lpf-ib 2015-02-08 17:19:42.101405928 +0100 -+++ dhcp-4.3.2b1/common/lpf.c 2015-02-08 17:36:15.072329845 +0100 +--- dhcp-4.3.2b1/common/lpf.c.lpf-ib 2015-02-26 09:49:40.546785596 +0100 ++++ dhcp-4.3.2b1/common/lpf.c 2015-02-26 09:49:40.562785385 +0100 @@ -47,6 +47,17 @@ #include #include @@ -123,7 +123,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c #endif #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) -@@ -80,10 +91,20 @@ int if_register_lpf (info) +@@ -80,10 +94,20 @@ int if_register_lpf (info) struct sockaddr common; } sa; struct ifreq ifr; @@ -146,7 +146,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || errno == EAFNOSUPPORT || errno == EINVAL) { -@@ -106,6 +127,7 @@ int if_register_lpf (info) +@@ -106,6 +130,7 @@ int if_register_lpf (info) /* Bind to the interface name */ memset (&sa, 0, sizeof sa); sa.ll.sll_family = AF_PACKET; @@ -154,7 +154,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c sa.ll.sll_ifindex = ifr.ifr_ifindex; if (bind (sock, &sa.common, sizeof sa)) { if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || -@@ -122,8 +144,6 @@ int if_register_lpf (info) +@@ -122,8 +147,6 @@ int if_register_lpf (info) } @@ -163,7 +163,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c return sock; } #endif /* USE_LPF_SEND || USE_LPF_RECEIVE */ -@@ -178,6 +198,8 @@ void if_deregister_send (info) +@@ -178,6 +201,8 @@ void if_deregister_send (info) in bpf includes... */ extern struct sock_filter dhcp_bpf_filter []; extern int dhcp_bpf_filter_len; @@ -172,7 +172,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c #if defined (HAVE_TR_SUPPORT) extern struct sock_filter dhcp_bpf_tr_filter []; -@@ -196,11 +218,12 @@ void if_register_receive (info) +@@ -196,11 +221,12 @@ void if_register_receive (info) #ifdef PACKET_AUXDATA { int val = 1; @@ -190,7 +190,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c } } } -@@ -250,15 +273,28 @@ static void lpf_gen_filter_setup (info) +@@ -250,15 +276,28 @@ static void lpf_gen_filter_setup (info) memset(&p, 0, sizeof(p)); @@ -228,7 +228,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p, sizeof p) < 0) { -@@ -315,6 +351,54 @@ static void lpf_tr_filter_setup (info) +@@ -315,6 +354,54 @@ static void lpf_tr_filter_setup (info) #endif /* USE_LPF_RECEIVE */ #ifdef USE_LPF_SEND @@ -283,7 +283,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c ssize_t send_packet (interface, packet, raw, len, from, to, hto) struct interface_info *interface; struct packet *packet; -@@ -335,6 +419,11 @@ ssize_t send_packet (interface, packet, +@@ -335,6 +422,11 @@ ssize_t send_packet (interface, packet, return send_fallback (interface, packet, raw, len, from, to, hto); @@ -295,7 +295,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c if (hto == NULL && interface->anycast_mac_addr.hlen) hto = &interface->anycast_mac_addr; -@@ -355,6 +444,42 @@ ssize_t send_packet (interface, packet, +@@ -355,6 +447,42 @@ ssize_t send_packet (interface, packet, #endif /* USE_LPF_SEND */ #ifdef USE_LPF_RECEIVE @@ -338,7 +338,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c ssize_t receive_packet (interface, buf, len, from, hfrom) struct interface_info *interface; unsigned char *buf; -@@ -380,6 +505,10 @@ ssize_t receive_packet (interface, buf, +@@ -380,6 +508,10 @@ ssize_t receive_packet (interface, buf, .msg_controllen = sizeof(cmsgbuf), }; @@ -349,7 +349,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c length = recvmsg (interface->rfdesc, &msg, 0); if (length <= 0) return length; -@@ -489,11 +618,33 @@ void maybe_setup_fallback () +@@ -489,11 +621,33 @@ void maybe_setup_fallback () #endif #if defined (USE_LPF_RECEIVE) || defined (USE_LPF_HWADDR) @@ -386,7 +386,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c if (strlen(name) >= sizeof(tmp.ifr_name)) { log_fatal("Device name too long: \"%s\"", name); -@@ -507,16 +658,62 @@ get_hw_addr(const char *name, struct har +@@ -507,16 +661,61 @@ get_hw_addr(const char *name, struct har memset(&tmp, 0, sizeof(tmp)); strcpy(tmp.ifr_name, name); if (ioctl(sock, SIOCGIFHWADDR, &tmp) < 0) { @@ -406,8 +406,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c + memcpy(sll->sll_addr, sa->sa_data, sizeof (sll->sll_addr)); + switch (sll->sll_hatype) { + case ARPHRD_INFINIBAND: -+ /* ioctl limits hardware addresses to 8 bytes */ -+ sll->sll_halen = 8; ++ sll->sll_halen = HARDWARE_ADDR_LEN_IOCTL; + break; + default: + break; @@ -452,7 +451,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c break; case ARPHRD_IEEE802: #ifdef ARPHRD_IEEE802_TR -@@ -524,18 +721,48 @@ get_hw_addr(const char *name, struct har +@@ -524,18 +723,50 @@ get_hw_addr(const char *name, struct har #endif /* ARPHRD_IEEE802_TR */ hw->hlen = 7; hw->hbuf[0] = HTYPE_IEEE802; @@ -491,9 +490,11 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c + 20); + } + -+ hw->hlen = 1; ++ hw->hlen = HARDWARE_ADDR_LEN_IOCTL + 1; + hw->hbuf[0] = HTYPE_INFINIBAND; -+ memcpy(&hw->hbuf[1], &sll->sll_addr[sll->sll_halen - 8], 8); ++ memcpy(&hw->hbuf[1], ++ &sll->sll_addr[sll->sll_halen - HARDWARE_ADDR_LEN_IOCTL], ++ HARDWARE_ADDR_LEN_IOCTL); break; #if defined(ARPHRD_PPP) case ARPHRD_PPP: @@ -505,7 +506,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c hw->hlen = 0; hw->hbuf[0] = HTYPE_RESERVED; /* 0xdeadbeef should never occur on the wire, -@@ -548,10 +775,13 @@ get_hw_addr(const char *name, struct har +@@ -548,10 +779,13 @@ get_hw_addr(const char *name, struct har break; #endif default: @@ -524,7 +525,7 @@ diff -up dhcp-4.3.2b1/common/lpf.c.lpf-ib dhcp-4.3.2b1/common/lpf.c #endif diff -up dhcp-4.3.2b1/common/socket.c.lpf-ib dhcp-4.3.2b1/common/socket.c --- dhcp-4.3.2b1/common/socket.c.lpf-ib 2015-01-29 14:52:57.000000000 +0100 -+++ dhcp-4.3.2b1/common/socket.c 2015-02-08 17:19:42.118405688 +0100 ++++ dhcp-4.3.2b1/common/socket.c 2015-02-26 09:49:40.562785385 +0100 @@ -328,7 +328,7 @@ void if_register_send (info) info->wfdesc = if_register_socket(info, AF_INET, 0, NULL); /* If this is a normal IPv4 address, get the hardware address. */ @@ -562,9 +563,19 @@ diff -up dhcp-4.3.2b1/common/socket.c.lpf-ib dhcp-4.3.2b1/common/socket.c if (!quiet_interface_discovery) { if (info->shared_network != NULL) { diff -up dhcp-4.3.2b1/includes/dhcpd.h.lpf-ib dhcp-4.3.2b1/includes/dhcpd.h ---- dhcp-4.3.2b1/includes/dhcpd.h.lpf-ib 2015-02-08 17:19:42.108405829 +0100 -+++ dhcp-4.3.2b1/includes/dhcpd.h 2015-02-08 17:19:42.119405674 +0100 -@@ -1264,6 +1264,7 @@ struct interface_info { +--- dhcp-4.3.2b1/includes/dhcpd.h.lpf-ib 2015-02-26 09:49:40.554785491 +0100 ++++ dhcp-4.3.2b1/includes/dhcpd.h 2015-02-26 09:50:12.210369312 +0100 +@@ -440,6 +440,9 @@ struct packet { + + #define HARDWARE_ADDR_LEN 20 + ++/* ioctl limits hardware addresses to 8 bytes */ ++#define HARDWARE_ADDR_LEN_IOCTL 8 ++ + struct hardware { + u_int8_t hlen; + u_int8_t hbuf[HARDWARE_ADDR_LEN + 1]; +@@ -1264,6 +1267,7 @@ struct interface_info { struct shared_network *shared_network; /* Networks connected to this interface. */ struct hardware hw_address; /* Its physical address. */ @@ -572,7 +583,7 @@ diff -up dhcp-4.3.2b1/includes/dhcpd.h.lpf-ib dhcp-4.3.2b1/includes/dhcpd.h struct in_addr *addresses; /* Addresses associated with this * interface. */ -@@ -2475,7 +2476,7 @@ void print_dns_status (int, struct dhcp_ +@@ -2475,7 +2479,7 @@ void print_dns_status (int, struct dhcp_ #endif const char *print_time(TIME); diff --git a/dhcp.spec b/dhcp.spec index 6b4933c..3ca6649 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -18,7 +18,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: 4.3.2 -Release: 0.4%{prever}%{?dist} +Release: 0.5%{prever}%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -675,6 +675,9 @@ done %doc doc/html/ %changelog +* Wed Feb 25 2015 Jiri Popelka - 12:4.3.2-0.5b1 +- correctly set IB's hw->hlen (#1185075) + * Tue Feb 17 2015 Jiri Popelka - 12:4.3.2-0.4b1 - dhclient-script: use 'ip addr replace' for both BOUND & RENEW