dhcp/dhcp-IPoIB-log-id.patch
Jiri Popelka 9568cf3620 4.3.2b1
2015-02-08 18:31:39 +01:00

264 lines
9.0 KiB
Diff

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
@@ -77,6 +77,42 @@ const int dhcp_type_name_max = ((sizeof
# define send_packet trace_packet_send
#endif
+char *print_client_identifier_from_packet (packet)
+ struct packet *packet;
+{
+ struct option_cache *oc;
+ struct data_string client_identifier;
+ char *ci;
+
+ memset (&client_identifier, 0, sizeof client_identifier);
+
+ oc = lookup_option (&dhcp_universe, packet -> options,
+ DHO_DHCP_CLIENT_IDENTIFIER);
+ if (oc &&
+ evaluate_option_cache (&client_identifier,
+ packet, (struct lease *)0,
+ (struct client_state *)0,
+ packet -> options,
+ (struct option_state *)0,
+ &global_scope, oc, MDL)) {
+ ci = print_hw_addr (HTYPE_INFINIBAND, client_identifier.len, client_identifier.data);
+ data_string_forget (&client_identifier, MDL);
+ return ci;
+ } else
+ return "\"no client id\"";
+}
+
+char *print_hw_addr_or_client_id (packet)
+ struct packet *packet;
+{
+ if (packet -> raw -> htype == HTYPE_INFINIBAND)
+ return print_client_identifier_from_packet (packet);
+ else
+ return print_hw_addr (packet -> raw -> htype,
+ packet -> raw -> hlen,
+ packet -> raw -> chaddr);
+}
+
void
dhcp (struct packet *packet) {
int ms_nulltp = 0;
@@ -105,9 +141,7 @@ dhcp (struct packet *packet) {
log_info("%s from %s via %s: %s", s,
(packet->raw->htype
- ? print_hw_addr(packet->raw->htype,
- packet->raw->hlen,
- packet->raw->chaddr)
+ ? print_hw_addr_or_client_id(packet)
: "<no identifier>"),
packet->raw->giaddr.s_addr
? inet_ntoa(packet->raw->giaddr)
@@ -289,9 +323,7 @@ void dhcpdiscover (packet, ms_nulltp)
*/
snprintf (msgbuf, sizeof msgbuf, "DHCPDISCOVER from %s %s%s%svia %s",
(packet -> raw -> htype
- ? print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr)
+ ? print_hw_addr_or_client_id (packet)
: (lease
? print_hex_1(lease->uid_len, lease->uid, 60)
: "<no identifier>")),
@@ -481,9 +513,7 @@ void dhcprequest (packet, ms_nulltp, ip_
"DHCPREQUEST for %s%s from %s %s%s%svia %s",
piaddr (cip), smbuf,
(packet -> raw -> htype
- ? print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr)
+ ? print_hw_addr_or_client_id(packet)
: (lease
? print_hex_1(lease->uid_len, lease->uid, 60)
: "<no identifier>")),
@@ -724,9 +754,7 @@ void dhcprelease (packet, ms_nulltp)
if ((oc = lookup_option (&dhcp_universe, packet -> options,
DHO_DHCP_REQUESTED_ADDRESS))) {
log_info ("DHCPRELEASE from %s specified requested-address.",
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr));
+ print_hw_addr_or_client_id(packet));
}
oc = lookup_option (&dhcp_universe, packet -> options,
@@ -800,9 +828,7 @@ void dhcprelease (packet, ms_nulltp)
"DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)",
cstr,
(packet -> raw -> htype
- ? print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr)
+ ? print_hw_addr_or_client_id(packet)
: (lease
? print_hex_1(lease->uid_len, lease->uid, 60)
: "<no identifier>")),
@@ -891,9 +917,7 @@ void dhcpdecline (packet, ms_nulltp)
"DHCPDECLINE of %s from %s %s%s%svia %s",
piaddr (cip),
(packet -> raw -> htype
- ? print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr)
+ ? print_hw_addr_or_client_id(packet)
: (lease
? print_hex_1(lease->uid_len, lease->uid, 60)
: "<no identifier>")),
@@ -1544,8 +1568,7 @@ void dhcpinform (packet, ms_nulltp)
/* Report what we're sending. */
snprintf(msgbuf, sizeof msgbuf, "DHCPACK to %s (%s) via", piaddr(cip),
(packet->raw->htype && packet->raw->hlen) ?
- print_hw_addr(packet->raw->htype, packet->raw->hlen,
- packet->raw->chaddr) :
+ print_hw_addr_or_client_id(packet) :
"<no client hardware address>");
log_info("%s %s", msgbuf, gip.len ? piaddr(gip) :
packet->interface->name);
@@ -1711,9 +1734,7 @@ void nak_lease (packet, cip, network_gro
/* Report what we're sending... */
log_info ("DHCPNAK on %s to %s via %s",
piaddr (*cip),
- print_hw_addr (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr),
+ print_hw_addr_or_client_id(packet),
packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name);
@@ -3617,7 +3638,7 @@ void dhcp_reply (lease)
? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
: "BOOTREPLY"),
piaddr (lease -> ip_addr),
- (lease -> hardware_addr.hlen
+ (lease -> hardware_addr.hlen > 1
? print_hw_addr (lease -> hardware_addr.hbuf [0],
lease -> hardware_addr.hlen - 1,
&lease -> hardware_addr.hbuf [1])
@@ -4171,10 +4192,7 @@ int find_lease (struct lease **lp,
if (uid_lease) {
if (uid_lease->binding_state == FTS_ACTIVE) {
log_error ("client %s has duplicate%s on %s",
- (print_hw_addr
- (packet -> raw -> htype,
- packet -> raw -> hlen,
- packet -> raw -> chaddr)),
+ (print_hw_addr_or_client_id(packet)),
" leases",
(ip_lease -> subnet ->
shared_network -> name));
@@ -4341,9 +4359,7 @@ int find_lease (struct lease **lp,
log_error("uid lease %s for client %s is duplicate "
"on %s",
piaddr(uid_lease->ip_addr),
- print_hw_addr(packet->raw->htype,
- packet->raw->hlen,
- packet->raw->chaddr),
+ print_hw_addr_or_client_id(packet),
uid_lease->subnet->shared_network->name);
if (!packet -> raw -> ciaddr.s_addr &&