]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/dhcp-4.2.2-gpxe-cid.patch
kernel: update to 3.10.23.
[people/teissler/ipfire-2.x.git] / src / patches / dhcp-4.2.2-gpxe-cid.patch
CommitLineData
78ab9b04
MT
1diff -up dhcp-4.2.2/client/dhclient.c.gpxe-cid dhcp-4.2.2/client/dhclient.c
2--- dhcp-4.2.2/client/dhclient.c.gpxe-cid 2011-09-16 18:23:20.190453902 +0200
3+++ dhcp-4.2.2/client/dhclient.c 2011-09-16 18:27:15.568463599 +0200
4@@ -58,6 +58,13 @@ const char *path_dhclient_pid = NULL;
5 static char path_dhclient_script_array[] = _PATH_DHCLIENT_SCRIPT;
6 char *path_dhclient_script = path_dhclient_script_array;
7
8+/* Default Prefix */
9+static unsigned char default_prefix[12] = {
10+ 0xff, 0x00, 0x00, 0x00,
11+ 0x00, 0x00, 0x02, 0x00,
12+ 0x00, 0x02, 0xc9, 0x00
13+};
14+
15 /* False (default) => we write and use a pid file */
16 isc_boolean_t no_pid_file = ISC_FALSE;
17
18@@ -1250,6 +1257,12 @@ int find_subnet (struct subnet **sp,
19 static void setup_ib_interface(struct interface_info *ip)
20 {
21 struct group *g;
22+ struct hardware *hw = &ip->hw_address;
23+ char client_id[64];
24+ char *arg_conf = NULL;
25+ int arg_conf_len = 0;
26+ isc_result_t status;
27+ struct parse *cfile = (struct parse *)0;
28
29 /* Set the broadcast flag */
30 ip->client->config->bootp_broadcast_always = 1;
31@@ -1266,8 +1279,39 @@ static void setup_ib_interface(struct in
32 }
33 }
34
35- /* No client ID specified */
36- log_fatal("dhcp-client-identifier must be specified for InfiniBand");
37+ /*
38+ * No client ID specified, make up one based on a default
39+ * "prefix" and the port GUID.
40+ *
41+ * NOTE: This is compatible with what gpxe does.
42+ */
43+ sprintf(client_id, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
44+ default_prefix[0], default_prefix[1], default_prefix[2],
45+ default_prefix[3], default_prefix[4], default_prefix[5],
46+ default_prefix[6], default_prefix[7], default_prefix[8],
47+ default_prefix[9], default_prefix[10], default_prefix[11],
48+ hw->hbuf[1], hw->hbuf[2], hw->hbuf[3], hw->hbuf[4],
49+ hw->hbuf[5], hw->hbuf[6], hw->hbuf[7], hw->hbuf[8]);
50+
51+ arg_conf_len = asprintf(&arg_conf,
52+ "send dhcp-client-identifier %s;",
53+ client_id);
54+
55+ if ((arg_conf == 0) || (arg_conf_len <= 0))
56+ log_fatal("Unable to send option dhcp-client-identifier");
57+
58+ status = new_parse(&cfile, -1, arg_conf, arg_conf_len,
59+ "Automatic Infiniband client identifier", 0);
60+
61+ if ((status != ISC_R_SUCCESS) || (cfile->warnings_occurred))
62+ log_fatal("Failed to parse Infiniband client identifier");
63+
64+ parse_client_statement(cfile, NULL, ip->client->config);
65+
66+ if (cfile->warnings_occurred)
67+ log_fatal("Failed to parse Infiniband client identifier");
68+
69+ end_parse(&cfile);
70 }
71
72 /* Individual States:
73diff -up dhcp-4.2.2/common/lpf.c.gpxe-cid dhcp-4.2.2/common/lpf.c
74--- dhcp-4.2.2/common/lpf.c.gpxe-cid 2011-09-16 18:23:20.183453996 +0200
75+++ dhcp-4.2.2/common/lpf.c 2011-09-16 18:25:28.235804421 +0200
76@@ -591,6 +591,37 @@ void maybe_setup_fallback ()
77 }
78 }
79
80+static unsigned char * get_ib_hw_addr(char * name)
81+{
82+ struct ifaddrs *ifaddrs;
83+ struct ifaddrs *ifa;
84+ struct sockaddr_ll *sll = NULL;
85+ static unsigned char hw_addr[8];
86+
87+ if (getifaddrs(&ifaddrs) == -1)
88+ return NULL;
89+
90+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
91+ if (ifa->ifa_addr == NULL)
92+ continue;
93+ if (ifa->ifa_addr->sa_family != AF_PACKET)
94+ continue;
95+ if (ifa->ifa_flags & IFF_LOOPBACK)
96+ continue;
97+ if (strcmp(ifa->ifa_name, name) == 0) {
98+ sll = (struct sockaddr_ll *)(void *)ifa->ifa_addr;
99+ break;
100+ }
101+ }
102+ if (sll == NULL) {
103+ freeifaddrs(ifaddrs);
104+ return NULL;
105+ }
106+ memcpy(hw_addr, &sll->sll_addr[sll->sll_halen - 8], 8);
107+ freeifaddrs(ifaddrs);
108+ return (unsigned char *)&hw_addr;
109+}
110+
111 void
112 get_hw_addr(struct interface_info *info)
113 {
114@@ -599,6 +630,7 @@ get_hw_addr(struct interface_info *info)
115 struct ifaddrs *ifaddrs;
116 struct ifaddrs *ifa;
117 struct sockaddr_ll *sll = NULL;
118+ unsigned char *hw_addr;
119
120 if (getifaddrs(&ifaddrs) == -1)
121 log_fatal("Failed to get interfaces");
122@@ -660,6 +692,10 @@ get_hw_addr(struct interface_info *info)
123
124 hw->hlen = 1;
125 hw->hbuf[0] = HTYPE_INFINIBAND;
126+ hw_addr = get_ib_hw_addr(name);
127+ if (!hw_addr)
128+ log_fatal("Failed getting %s hw addr", name);
129+ memcpy (&hw->hbuf [1], hw_addr, 8);
130 break;
131 #if defined(ARPHRD_PPP)
132 case ARPHRD_PPP: