additional support for dhcp lease, used in cisco uBRs' Fix: patch file /usr/ports/net/isc-dhcp3-server/files/patch-dlq: === cut ===
It's great, but any reason for use it only for FreeBSD? Have you tried to send the patch to ISC people? -- Sem.
State Changed From-To: open->feedback Forward PR to maintainer.
here is patch for new option in port. === cut === diff -ruN ../isc-dhcp3-server.original/Makefile ./Makefile --- ../isc-dhcp3-server.original/Makefile Mon Jun 6 15:39:27 2005 +++ ./Makefile Mon Jun 6 16:06:10 2005 @@ -34,7 +34,8 @@ DHCP_LDAP "add experimental LDAP backend support" off \ DHCP_LDAP_SSL "support LDAP connection over SSL/TLS" on \ OPENSSL_BASE "use the base system OpenSSL (required by TLS)" on \ - OPENSSL_PORT "use OpenSSL from ports (required by TLS)" off + OPENSSL_PORT "use OpenSSL from ports (required by TLS)" off \ + PATCH_DLQ "use DHCPLEASEDQUERY patch for cisco uBRs'" off .endif .include <bsd.port.pre.mk> @@ -200,7 +201,8 @@ post-patch: patch-scripts patch-makefile-conf \ patch-makefiles-dist patch-man-pages \ patch-pkgmessage patch-site-conf \ - patch-rc-scripts + patch-rc-scripts \ + patch-dlq patch-scripts: @${REINPLACE_CMD} ${REINPLACE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \ @@ -258,6 +260,11 @@ .else @${REINPLACE_CMD} -e '/^%%LDAP%%/d' ${PKGMESSAGE} .endif +.endif + +patch-dlq: +.if defined(WITH_PATCH_DLQ) + @${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-dlq .endif # Post-install diff -ruN ../isc-dhcp3-server.original/files/extra-patch-dlq ./files/extra-patch-dlq --- ../isc-dhcp3-server.original/files/extra-patch-dlq Thu Jan 1 05:00:00 1970 +++ ./files/extra-patch-dlq Mon Jun 6 14:51:12 2005 @@ -0,0 +1,261 @@ +diff -ruN ../../work/dhcp-3.0.2/includes/dhcp.h ./includes/dhcp.h +--- ../../work/dhcp-3.0.2/includes/dhcp.h Thu Jun 10 23:59:29 2004 ++++ ./includes/dhcp.h Mon Jun 6 14:45:47 2005 +@@ -168,6 +168,11 @@ + #define DHCPNAK 6 + #define DHCPRELEASE 7 + #define DHCPINFORM 8 ++#define DHCPLEASEQUERY 13 ++#define DHCPLEASEKNOWN 14 ++#define DHCPLEASEUNKNOWN 15 ++#define DHCPLEASEACTIVE 16 ++#define DHCPUNIMPLEMENTED 17 + + /* Relay Agent Information option subtypes: */ + #define RAI_CIRCUIT_ID 1 +diff -ruN ../../work/dhcp-3.0.2/includes/dhcpd.h ./includes/dhcpd.h +--- ../../work/dhcp-3.0.2/includes/dhcpd.h Mon Jun 6 14:48:58 2005 ++++ ./includes/dhcpd.h Mon Jun 6 14:46:21 2005 +@@ -1374,6 +1374,7 @@ + void dhcprelease PROTO ((struct packet *, int)); + void dhcpdecline PROTO ((struct packet *, int)); + void dhcpinform PROTO ((struct packet *, int)); ++void dhcpleasequery PROTO ((struct packet *, int)); + void nak_lease PROTO ((struct packet *, struct iaddr *cip)); + void ack_lease PROTO ((struct packet *, struct lease *, + unsigned int, TIME, char *, int)); +diff -ruN ../../work/dhcp-3.0.2/server/Makefile.dist ./server/Makefile.dist +--- ../../work/dhcp-3.0.2/server/Makefile.dist Mon Jun 6 14:48:58 2005 ++++ ./server/Makefile.dist Mon Jun 6 14:47:06 2005 +@@ -25,9 +25,9 @@ + CATMANPAGES = dhcpd.cat8 dhcpd.conf.cat5 dhcpd.leases.cat5 + SEDMANPAGES = dhcpd.man8 dhcpd.conf.man5 dhcpd.leases.man5 + SRCS = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \ +- omapi.c mdb.c stables.c salloc.c ddns.c ++ omapi.c mdb.c stables.c salloc.c ddns.c dhcpleasequery.c + OBJS = dhcpd.o dhcp.o bootp.o confpars.o db.o class.o failover.o \ +- omapi.o mdb.o stables.o salloc.o ddns.o ++ omapi.o mdb.o stables.o salloc.o ddns.o dhcpleasequery.o + PROG = dhcpd + MAN = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5 + +diff -ruN ../../work/dhcp-3.0.2/server/dhcp.c ./server/dhcp.c +--- ../../work/dhcp-3.0.2/server/dhcp.c Wed Nov 24 22:39:19 2004 ++++ ./server/dhcp.c Mon Jun 6 14:48:04 2005 +@@ -226,6 +226,13 @@ + case DHCPACK: + case DHCPOFFER: + case DHCPNAK: ++ case DHCPLEASEACTIVE: ++ case DHCPLEASEKNOWN: ++ case DHCPLEASEUNKNOWN: ++ break; ++ ++ case DHCPLEASEQUERY: ++ dhcpleasequery(packet, ms_nulltp); + break; + + default: +diff -ruN ../../work/dhcp-3.0.2/server/dhcpleasequery.c ./server/dhcpleasequery.c +--- ../../work/dhcp-3.0.2/server/dhcpleasequery.c Thu Jan 1 05:00:00 1970 ++++ ./server/dhcpleasequery.c Mon Jun 6 14:48:20 2005 +@@ -0,0 +1,199 @@ ++#include "dhcpd.h" ++ ++void dhcpleasequery (packet, ms_nulltp) ++struct packet *packet; ++int ms_nulltp; ++{ ++ ++ //printf("Received LEASEQUERY message\n"); ++ struct lease *lease = (struct lease *)0; ++ struct iaddr cip; ++ struct sockaddr_in to; ++ //unsigned packet_length; ++ unsigned char dhcpMsgType; ++ struct dhcp_packet *raw = packet -> raw; ++ struct option_state *options = (struct option_state *)0; ++ struct option_cache *oc = (struct option_cache *)0; ++ struct data_string prl; ++ char msgbuf [1024]; ++ uint leaseTime; ++ ++ option_state_allocate(&options, MDL); ++ cip.len = sizeof packet -> raw -> ciaddr; ++ memcpy (cip.iabuf, &packet -> raw -> ciaddr, sizeof packet -> raw -> ciaddr); ++ //TODO if IP is all zeros, then set dhcp message type to DHCPUNIMPLEMENTED ++ find_lease_by_ip_addr(&lease, cip, MDL); ++ ++ if(!lease) { ++ dhcpMsgType = DHCPNAK; ++ snprintf( ++ msgbuf, ++ sizeof msgbuf, ++ "DHCPLEASEQUERY failed for c:%s, y:%s, s:%s, g:%s", ++ inet_ntoa(packet -> raw -> ciaddr), ++ inet_ntoa(packet -> raw -> yiaddr), ++ inet_ntoa(packet -> raw -> siaddr), ++ inet_ntoa(packet -> raw -> giaddr) ++ ); ++ log_info(msgbuf); ++ } else { ++ if(lease -> binding_state == FTS_ACTIVE) { ++ dhcpMsgType = DHCPACK; ++ log_info("DHCPLEASEQUERY success"); ++ } else { ++ dhcpMsgType = DHCPNAK; ++ } ++ memcpy(packet -> raw -> chaddr, ++ &lease -> hardware_addr.hbuf [1], sizeof packet -> raw -> chaddr); ++ packet -> raw -> hlen = lease -> hardware_addr.hlen - 1; ++ packet -> raw -> htype = lease -> hardware_addr.hbuf [0]; ++ ++ if(dhcpMsgType == DHCPACK && lease -> ends > cur_time) { ++ if(!option_cache_allocate(&oc, MDL)) { ++ log_error("No memory for lease time option."); ++ option_state_dereference(&options, MDL); ++ return; ++ } ++ leaseTime = htonl(lease -> ends - cur_time); ++ if (!make_const_data(&oc -> expression, (char*)&leaseTime, sizeof leaseTime, 0, 0, MDL)) { ++ log_error("No memory for expr_const expression."); ++ option_cache_dereference(&oc, MDL); ++ option_state_dereference(&options, MDL); ++ return; ++ } ++ oc -> option = dhcp_universe.options[DHO_DHCP_LEASE_TIME]; ++ save_option(&dhcp_universe, options, oc); ++ option_cache_dereference(&oc, MDL); ++ } ++ ++ // Set the relay agent info. ++ if(lease -> agent_options) { ++ pair p; ++ int len = 0; ++ char agent_options[255]; ++ for(p = lease -> agent_options -> first; p; p = p -> cdr) { ++ oc = (struct option_cache *)p -> car; ++ if(oc -> data.len) { ++ memcpy(&agent_options[len], (char*)&oc->option->code, 1); ++ memcpy(&agent_options[len+1], (char*)&oc->data.len, 1); ++ memcpy(&agent_options[len+2], oc->data.data, oc->data.len); ++ len += oc -> data.len + 2; ++ } ++ } ++ oc = (struct option_cache *)0; ++ if(!option_cache_allocate (&oc, MDL)) { ++ log_error("No memory for lease time option."); ++ option_state_dereference (&options, MDL); ++ return; ++ } ++ if(!make_const_data(&oc -> expression, (char*)&agent_options, len, 0, 0, MDL)) { ++ log_error("No memory for expr_const expression."); ++ option_cache_dereference(&oc, MDL); ++ option_state_dereference(&options, MDL); ++ return; ++ } ++ oc -> option = dhcp_universe.options[DHO_DHCP_AGENT_OPTIONS]; ++ save_option(&dhcp_universe, options, oc); ++ option_cache_dereference(&oc, MDL); ++ } ++ } ++ ++ // Set the message type ++ packet -> raw -> op = BOOTREPLY; ++ ++ // Set dhcp message type ++ if(!option_cache_allocate(&oc, MDL)) { ++ log_error("No memory for dhcp message type."); ++ option_state_dereference(&options, MDL); ++ return; ++ } ++ if(!make_const_data(&oc -> expression, &dhcpMsgType, sizeof dhcpMsgType, 0, 0, MDL)) { ++ log_error("No memory for expr_const expression."); ++ option_cache_dereference(&oc, MDL); ++ option_state_dereference(&options, MDL); ++ return; ++ } ++ oc -> option = dhcp_universe.options[DHO_DHCP_MESSAGE_TYPE]; ++ save_option(&dhcp_universe, options, oc); ++ option_cache_dereference(&oc, MDL); ++ ++ ++#if 0 ++ memset(&prl, 0, sizeof prl); ++ ++ /* Use the parameter list from the scope if there is one. */ ++ oc = lookup_option( ++ &dhcp_universe, ++ options, ++ DHO_DHCP_PARAMETER_REQUEST_LIST ++ ); ++ ++ /* Otherwise, if the client has provided a list of options ++ that it wishes returned, use it to prioritize. Otherwise, ++ prioritize based on the default priority list. */ ++ ++ if (!oc) oc = lookup_option(&dhcp_universe, packet -> options, DHO_DHCP_PARAMETER_REQUEST_LIST); ++ if (oc) evaluate_option_cache(&prl, packet, (struct lease *)0, (struct client_state *)0, packet -> options, options, &global_scope, oc, MDL); ++ ++ //printf("Parameter Request List length is %d: %d, %d\n", prl.len, prl.data[0], prl.data[1]); ++ ++ /* Set up the option buffer... */ ++ packet -> packet_length = cons_options( ++ packet, ++ raw, ++ lease, ++ (struct client_state *)0, ++ 0, ++ packet -> options, ++ options, ++ &global_scope, ++ 0, ++ 0, ++ 0, ++ prl.len ? &prl : (struct data_string *)0, ++ (char *)0 ++ ); ++#endif ++ ++ /* Set up the option buffer... */ ++ packet -> packet_length = cons_options( ++ packet, ++ raw, ++ lease, ++ (struct client_state *)0, ++ 0, ++ packet -> options, ++ options, ++ &global_scope, ++ 0, 0, 0, ++ (struct data_string *)0, ++ (char *)0 ++ ); ++ option_state_dereference(&options, MDL); ++ ++ to.sin_family = AF_INET; ++#ifdef HAVE_SA_LEN ++ to.sin_len = sizeof to; ++#endif ++ memset(to.sin_zero, 0, sizeof to.sin_zero); ++ ++ /* LEASEQUERY packets must be sent to gateway address */ ++ if(packet -> raw -> giaddr.s_addr) { ++ to.sin_addr = packet -> raw -> giaddr; ++ if (packet -> raw -> giaddr.s_addr != htonl(INADDR_LOOPBACK)) { ++ to.sin_port = local_port; ++ } else { ++ to.sin_port = remote_port; /* For debugging. */ ++ } ++ ++ if (fallback_interface) { ++ send_packet( ++ fallback_interface, ++ (struct packet *)0, ++ packet -> raw, packet -> packet_length, ++ packet -> raw -> siaddr, &to, ++ (struct hardware *)0 ++ ); ++ } ++ } ++} === cut === -- Dmitry Sukhodoev, servers maintainer of chics.ru
Responsible Changed From-To: freebsd-ports-bugs->sem Grab.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Dmitry, i want to take care of your submitted PR ports/79599 for net/isc-dhcpd3-server from Wed Apr 06 11:00:15 GMT 2005. Have you contacted the ISC-DHCP development people to send this patch over to them? I would really like to get this patch into the original ISC-DHCP distributions to make it available to the whole community instead of having it only locally in the FreeBSD port. What do you think about this? regards Joerg - -- The beginning is the most important part of the work. -Plato -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQFCqZQoSPOsGF+KA+MRAvj9AJ9OfgHz/7cjC7uNd5ZYZa95etoTlACgz4fW jL7P+tnnqWBzMJhdKBFQOwI= =uztn -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Sergey, i've attached a patch to fix PR ports/79599. After some discussions with the original PR submitter, i decided to let him maintain this externally, like the dhcp-ldap patch, and only include the necessary bits to get it fetched and included in the build process. This way, we do not "pollute" the CVS with this temporary patch, as the ISC people decided to include DHCPLEASEQUERY support in the upcoming dhcpd-3.1.0 release. I have tested the port with different OPTION settings on RELENG_4_11, RELENG_5_4 and 6.0-CURRENT on i386. Changelog: - added support for draft-ietf-dhc-leasequery-08.txt DHCPLEASEQUERY support Thanks to Dmitry V. Sukhodoev <raven@chics.ru> for providing this patch - introduced new OPTION to enable DHCPLEASEQUERY support I will go on now to fix PR ports/76820 and PR ports/76825, as soon as my jail is up and running. I have to reproduce and test this for myself as i did not received an answer from the PR submitter. regards Joerg - -- The beginning is the most important part of the work. -Plato -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQFCr8ZWSPOsGF+KA+MRAqCqAKCyNDQkH7M/kTjlnsY0P2F/0yf/lACeLeW0 W/qO1zyWgNiNGqiHPffTyiY= =8d1Z -----END PGP SIGNATURE-----
Joerg Pulz wrote: > After some discussions with the original PR submitter, i decided to let > him maintain this externally, like the dhcp-ldap patch, and only include > the necessary bits to get it fetched and included in the build process. > This way, we do not "pollute" the CVS with this temporary patch, as the I'm sure it's the best decision. I love it. -- Sem.
State Changed From-To: feedback->closed Committed, thanks!