Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 596257 Details for
Bug 626514
ISC dhcp does not support ppp and ipv6 as in`dhclient -6 -P`
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
diff beteen lpf.c from 4.2.3-8 to 4.2.3-9
89.patch (text/plain), 10.80 KB, created by
udo
on 2012-07-04 16:16:45 UTC
(
hide
)
Description:
diff beteen lpf.c from 4.2.3-8 to 4.2.3-9
Filename:
MIME Type:
Creator:
udo
Created:
2012-07-04 16:16:45 UTC
Size:
10.80 KB
patch
obsolete
>--- 8/lpf.c 2012-07-04 18:12:39.985370082 +0200 >+++ 9/lpf.c 2012-07-04 18:12:05.485201828 +0200 >@@ -42,6 +42,7 @@ > #include "includes/netinet/udp.h" > #include "includes/netinet/if_ether.h" > #include <net/if.h> >+#include <ifaddrs.h> > > #ifndef PACKET_AUXDATA > #define PACKET_AUXDATA 8 >@@ -59,6 +60,15 @@ > /* Reinitializes the specified interface after an address change. This > is not required for packet-filter APIs. */ > >+/* Default broadcast address for IPoIB */ >+static unsigned char default_ib_bcast_addr[20] = { >+ 0x00, 0xff, 0xff, 0xff, >+ 0xff, 0x12, 0x40, 0x1b, >+ 0x00, 0x00, 0x00, 0x00, >+ 0x00, 0x00, 0x00, 0x00, >+ 0xff, 0xff, 0xff, 0xff >+}; >+ > #ifdef USE_LPF_SEND > void if_reinitialize_send (info) > struct interface_info *info; >@@ -86,10 +96,21 @@ > struct sockaddr common; > } sa; > struct ifreq ifr; >+ int type; >+ int protocol; > > /* Make an LPF socket. */ >- if ((sock = socket(PF_PACKET, SOCK_RAW, >- htons((short)ETH_P_ALL))) < 0) { >+ get_hw_addr(info); >+ >+ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) { >+ type = SOCK_DGRAM; >+ protocol = ETHERTYPE_IP; >+ } else { >+ type = SOCK_RAW; >+ protocol = ETH_P_ALL; >+ } >+ >+ if ((sock = socket(PF_PACKET, type, htons((short)protocol))) < 0) { > if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || > errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || > errno == EAFNOSUPPORT || errno == EINVAL) { >@@ -112,6 +133,7 @@ > /* Bind to the interface name */ > memset (&sa, 0, sizeof sa); > sa.ll.sll_family = AF_PACKET; >+ sa.ll.sll_protocol = htons(protocol); > sa.ll.sll_ifindex = ifr.ifr_ifindex; > if (bind (sock, &sa.common, sizeof sa)) { > if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || >@@ -127,8 +149,6 @@ > log_fatal ("Bind socket to interface: %m"); > } > >- get_hw_addr(info->name, &info->hw_address); >- > return sock; > } > #endif /* USE_LPF_SEND || USE_LPF_RECEIVE */ >@@ -183,6 +203,8 @@ > in bpf includes... */ > extern struct sock_filter dhcp_bpf_filter []; > extern int dhcp_bpf_filter_len; >+extern struct sock_filter dhcp_ib_bpf_filter []; >+extern int dhcp_ib_bpf_filter_len; > > #if defined (HAVE_TR_SUPPORT) > extern struct sock_filter dhcp_bpf_tr_filter []; >@@ -200,11 +222,13 @@ > /* Open a LPF device and hang it on this interface... */ > info -> rfdesc = if_register_lpf (info); > >- val = 1; >- if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val, >- sizeof val) < 0) { >- if (errno != ENOPROTOOPT) >- log_fatal ("Failed to set auxiliary packet data: %m"); >+ if (info->hw_address.hbuf[0] != HTYPE_INFINIBAND) { >+ val = 1; >+ if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, >+ &val, sizeof val) < 0) { >+ if (errno != ENOPROTOOPT) >+ log_fatal ("Failed to set auxiliary packet data: %m"); >+ } > } > > #if defined (HAVE_TR_SUPPORT) >@@ -250,15 +274,28 @@ > > memset(&p, 0, sizeof(p)); > >- /* Set up the bpf filter program structure. This is defined in >- bpf.c */ >- p.len = dhcp_bpf_filter_len; >- p.filter = dhcp_bpf_filter; >- >- /* Patch the server port into the LPF program... >- XXX changes to filter program may require changes >- to the insn number(s) used below! XXX */ >- dhcp_bpf_filter [8].k = ntohs ((short)local_port); >+ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) { >+ /* Set up the bpf filter program structure. */ >+ p.len = dhcp_ib_bpf_filter_len; >+ p.filter = dhcp_ib_bpf_filter; >+ >+ /* Patch the server port into the LPF program... >+ XXX >+ changes to filter program may require changes >+ to the insn number(s) used below! >+ XXX */ >+ dhcp_ib_bpf_filter[6].k = ntohs ((short)local_port); >+ } else { >+ /* Set up the bpf filter program structure. >+ This is defined in bpf.c */ >+ p.len = dhcp_bpf_filter_len; >+ p.filter = dhcp_bpf_filter; >+ >+ /* Patch the server port into the LPF program... >+ XXX changes to filter program may require changes >+ to the insn number(s) used below! XXX */ >+ dhcp_bpf_filter [8].k = ntohs ((short)local_port); >+ } > > if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p, > sizeof p) < 0) { >@@ -315,6 +352,54 @@ > #endif /* USE_LPF_RECEIVE */ > > #ifdef USE_LPF_SEND >+ssize_t send_packet_ib(interface, packet, raw, len, from, to, hto) >+ struct interface_info *interface; >+ struct packet *packet; >+ struct dhcp_packet *raw; >+ size_t len; >+ struct in_addr from; >+ struct sockaddr_in *to; >+ struct hardware *hto; >+{ >+ unsigned ibufp = 0; >+ double ih [1536 / sizeof (double)]; >+ unsigned char *buf = (unsigned char *)ih; >+ ssize_t result; >+ >+ union sockunion { >+ struct sockaddr sa; >+ struct sockaddr_ll sll; >+ struct sockaddr_storage ss; >+ } su; >+ >+ assemble_udp_ip_header (interface, buf, &ibufp, from.s_addr, >+ to->sin_addr.s_addr, to->sin_port, >+ (unsigned char *)raw, len); >+ memcpy (buf + ibufp, raw, len); >+ >+ memset(&su, 0, sizeof(su)); >+ su.sll.sll_family = AF_PACKET; >+ su.sll.sll_protocol = htons(ETHERTYPE_IP); >+ >+ if (!(su.sll.sll_ifindex = if_nametoindex(interface->name))) { >+ errno = ENOENT; >+ log_error ("send_packet_ib: %m - failed to get if index"); >+ return -1; >+ } >+ >+ su.sll.sll_hatype = htons(HTYPE_INFINIBAND); >+ su.sll.sll_halen = sizeof(interface->bcast_addr); >+ memcpy(&su.sll.sll_addr, interface->bcast_addr, 20); >+ >+ result = sendto(interface->wfdesc, buf, ibufp + len, 0, >+ &su.sa, sizeof(su)); >+ >+ if (result < 0) >+ log_error ("send_packet_ib: %m"); >+ >+ return result; >+} >+ > ssize_t send_packet (interface, packet, raw, len, from, to, hto) > struct interface_info *interface; > struct packet *packet; >@@ -335,6 +420,11 @@ > return send_fallback (interface, packet, raw, > len, from, to, hto); > >+ if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) { >+ return send_packet_ib(interface, packet, raw, len, from, >+ to, hto); >+ } >+ > if (hto == NULL && interface->anycast_mac_addr.hlen) > hto = &interface->anycast_mac_addr; > >@@ -356,6 +446,42 @@ > #endif /* USE_LPF_SEND */ > > #ifdef USE_LPF_RECEIVE >+ssize_t receive_packet_ib (interface, buf, len, from, hfrom) >+ struct interface_info *interface; >+ unsigned char *buf; >+ size_t len; >+ struct sockaddr_in *from; >+ struct hardware *hfrom; >+{ >+ int length = 0; >+ int offset = 0; >+ unsigned char ibuf [1536]; >+ unsigned bufix = 0; >+ unsigned paylen; >+ >+ length = read(interface->rfdesc, ibuf, sizeof(ibuf)); >+ >+ if (length <= 0) >+ return length; >+ >+ offset = decode_udp_ip_header(interface, ibuf, bufix, from, >+ (unsigned)length, &paylen, 0); >+ >+ if (offset < 0) >+ return 0; >+ >+ bufix += offset; >+ length -= offset; >+ >+ if (length < paylen) >+ log_fatal("Internal inconsistency at %s:%d.", MDL); >+ >+ /* Copy out the data in the packet... */ >+ memcpy(buf, &ibuf[bufix], paylen); >+ >+ return (ssize_t)paylen; >+} >+ > ssize_t receive_packet (interface, buf, len, from, hfrom) > struct interface_info *interface; > unsigned char *buf; >@@ -382,6 +508,10 @@ > }; > struct cmsghdr *cmsg; > >+ if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) { >+ return receive_packet_ib(interface, buf, len, from, hfrom); >+ } >+ > length = recvmsg (interface -> rfdesc, &msg, 0); > if (length <= 0) > return length; >@@ -461,34 +591,77 @@ > } > } > >+static unsigned char * get_ib_hw_addr(char * name) >+{ >+ struct ifaddrs *ifaddrs; >+ struct ifaddrs *ifa; >+ struct sockaddr_ll *sll = NULL; >+ static unsigned char hw_addr[8]; >+ >+ if (getifaddrs(&ifaddrs) == -1) >+ return NULL; >+ >+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { >+ if (ifa->ifa_addr == NULL) >+ continue; >+ if (ifa->ifa_addr->sa_family != AF_PACKET) >+ continue; >+ if (ifa->ifa_flags & IFF_LOOPBACK) >+ continue; >+ if (strcmp(ifa->ifa_name, name) == 0) { >+ sll = (struct sockaddr_ll *)(void *)ifa->ifa_addr; >+ break; >+ } >+ } >+ if (sll == NULL) { >+ freeifaddrs(ifaddrs); >+ return NULL; >+ } >+ memcpy(hw_addr, &sll->sll_addr[sll->sll_halen - 8], 8); >+ freeifaddrs(ifaddrs); >+ return (unsigned char *)&hw_addr; >+} >+ > void >-get_hw_addr(const char *name, struct hardware *hw) { >- int sock; >- struct ifreq tmp; >- struct sockaddr *sa; >+get_hw_addr(struct interface_info *info) >+{ >+ struct hardware *hw = &info->hw_address; >+ char *name = info->name; >+ struct ifaddrs *ifaddrs; >+ struct ifaddrs *ifa; >+ struct sockaddr_ll *sll = NULL; >+ unsigned char *hw_addr; > >- if (strlen(name) >= sizeof(tmp.ifr_name)) { >- log_fatal("Device name too long: \"%s\"", name); >- } >+ if (getifaddrs(&ifaddrs) == -1) >+ log_fatal("Failed to get interfaces"); >+ >+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { >+ >+ if (ifa->ifa_addr == NULL) >+ continue; >+ >+ if (ifa->ifa_addr->sa_family != AF_PACKET) >+ continue; >+ >+ if (ifa->ifa_flags & IFF_LOOPBACK) >+ continue; > >- sock = socket(AF_INET, SOCK_DGRAM, 0); >- if (sock < 0) { >- log_fatal("Can't create socket for \"%s\": %m", name); >+ if (strcmp(ifa->ifa_name, name) == 0) { >+ sll = (struct sockaddr_ll *)(void *)ifa->ifa_addr; >+ break; >+ } > } > >- memset(&tmp, 0, sizeof(tmp)); >- strcpy(tmp.ifr_name, name); >- if (ioctl(sock, SIOCGIFHWADDR, &tmp) < 0) { >- log_fatal("Error getting hardware address for \"%s\": %m", >- name); >+ if (sll == NULL) { >+ freeifaddrs(ifaddrs); >+ log_fatal("Failed to get HW address for %s\n", name); > } > >- sa = &tmp.ifr_hwaddr; >- switch (sa->sa_family) { >+ switch (sll->sll_hatype) { > case ARPHRD_ETHER: > hw->hlen = 7; > hw->hbuf[0] = HTYPE_ETHER; >- memcpy(&hw->hbuf[1], sa->sa_data, 6); >+ memcpy(&hw->hbuf[1], sll->sll_addr, 6); > break; > case ARPHRD_IEEE802: > #ifdef ARPHRD_IEEE802_TR >@@ -496,18 +669,39 @@ > #endif /* ARPHRD_IEEE802_TR */ > hw->hlen = 7; > hw->hbuf[0] = HTYPE_IEEE802; >- memcpy(&hw->hbuf[1], sa->sa_data, 6); >+ memcpy(&hw->hbuf[1], sll->sll_addr, 6); > break; > case ARPHRD_FDDI: > hw->hlen = 17; > hw->hbuf[0] = HTYPE_FDDI; >- memcpy(&hw->hbuf[1], sa->sa_data, 16); >+ memcpy(&hw->hbuf[1], sll->sll_addr, 16); >+ break; >+ case ARPHRD_INFINIBAND: >+ /* For Infiniband, save the broadcast address and store >+ * the port GUID into the hardware address. >+ */ >+ if (ifa->ifa_flags & IFF_BROADCAST) { >+ struct sockaddr_ll *bll; >+ >+ bll = (struct sockaddr_ll *)ifa->ifa_broadaddr; >+ memcpy(&info->bcast_addr, bll->sll_addr, 20); >+ } else { >+ memcpy(&info->bcast_addr, default_ib_bcast_addr, >+ 20); >+ } >+ >+ hw->hlen = 1; >+ hw->hbuf[0] = HTYPE_INFINIBAND; >+ hw_addr = get_ib_hw_addr(name); >+ if (!hw_addr) >+ log_fatal("Failed getting %s hw addr", name); >+ memcpy (&hw->hbuf [1], hw_addr, 8); > break; > #if defined(ARPHRD_PPP) > case ARPHRD_PPP: > if (local_family != AF_INET6) >- log_fatal("Unsupported device type %d for \"%s\"", >- sa->sa_family, name); >+ log_fatal("Unsupported device type %ld for \"%s\"", >+ (long int)sll->sll_family, name); > hw->hlen = 0; > hw->hbuf[0] = HTYPE_RESERVED; > /* 0xdeadbeef should never occur on the wire, >@@ -520,10 +714,11 @@ > break; > #endif > default: >+ freeifaddrs(ifaddrs); > log_fatal("Unsupported device type %ld for \"%s\"", >- (long int)sa->sa_family, name); >+ (long int)sll->sll_family, name); > } > >- close(sock); >+ freeifaddrs(ifaddrs); > } > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 626514
:
443055
|
443060
|
443128
|
446301
|
446939
| 596257 |
598914
|
602341
|
602342
|
602343
|
602344
|
602345
|
740389
|
740393
|
740670
|
741830
|
741831
|
743452
|
743453
|
819281
|
819282
|
819283
|
821802
|
901378
|
901379
|
901380