Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcp6c no release option & extra light info logging #231

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions net/dhcp6/files/patch-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
extern int get_duid __P((char *, struct duid *));
extern void dhcp6_init_options __P((struct dhcp6_optinfo *));
extern void dhcp6_clear_options __P((struct dhcp6_optinfo *));
@@ -179,7 +179,7 @@ extern void duidfree __P((struct duid *)
extern int ifaddrconf __P((ifaddrconf_cmd_t, char *, struct sockaddr_in6 *,
int, int, int));
extern int safefile __P((const char *));
-
+extern int opt_norelease;
/* missing */
#ifndef HAVE_STRLCAT
extern size_t strlcat __P((char *, const char *, size_t));
118 changes: 110 additions & 8 deletions net/dhcp6/files/patch-dhcp6c.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,43 @@
int ctlsock = -1; /* control TCP port */
char *ctladdr = DEFAULT_CLIENT_CONTROL_ADDR;
char *ctlport = DEFAULT_CLIENT_CONTROL_PORT;
@@ -257,7 +257,7 @@ client6_init()
@@ -147,6 +147,7 @@ int client6_start __P((struct dhcp6_if *
static void info_printf __P((const char *, ...));

extern int client6_script __P((char *, int, struct dhcp6_optinfo *));
+int opt_norelease;

#define MAX_ELAPSED_TIME 0xffff

@@ -169,7 +170,7 @@ main(argc, argv)
else
progname++;

- while ((ch = getopt(argc, argv, "c:dDfik:p:")) != -1) {
+ while ((ch = getopt(argc, argv, "c:ndDfik:p:")) != -1) {
switch (ch) {
case 'c':
conffile = optarg;
@@ -192,6 +193,9 @@ main(argc, argv)
case 'p':
pid_file = optarg;
break;
+ case 'n':
+ opt_norelease = 1;
+ break;
default:
usage();
exit(0);
@@ -246,7 +250,7 @@ static void
usage()
{

- fprintf(stderr, "usage: dhcp6c [-c configfile] [-dDfi] "
+ fprintf(stderr, "usage: dhcp6c [-c configfile] [-ndDfi] "
"[-p pid-file] interface [interfaces...]\n");
}

@@ -257,7 +261,7 @@ client6_init()
{
struct addrinfo hints, *res;
static struct sockaddr_in6 sa6_allagent_storage;
Expand All @@ -25,7 +61,7 @@

/* get our DUID */
if (get_duid(DUID_FILE, &client_duid)) {
@@ -287,6 +287,20 @@ client6_init()
@@ -287,6 +291,20 @@ client6_init()
dprintf(LOG_ERR, FNAME, "socket");
exit(1);
}
Expand All @@ -46,7 +82,7 @@
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
&on, sizeof(on)) < 0) {
dprintf(LOG_ERR, FNAME,
@@ -337,13 +351,6 @@ client6_init()
@@ -337,13 +355,6 @@ client6_init()
}
freeaddrinfo(res);

Expand All @@ -60,7 +96,7 @@
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_INET6;
hints.ai_socktype = SOCK_DGRAM;
@@ -596,7 +603,7 @@ get_ifname(bpp, lenp, ifbuf, ifbuflen)
@@ -596,7 +607,7 @@ get_ifname(bpp, lenp, ifbuf, ifbuflen)
if (*lenp < ifnamelen || ifnamelen > ifbuflen)
return (-1);

Expand All @@ -69,7 +105,7 @@
memcpy(ifbuf, *bpp, ifnamelen);
if (ifbuf[ifbuflen - 1] != '\0')
return (-1); /* not null terminated */
@@ -763,6 +770,15 @@ client6_ifctl(ifname, command)
@@ -763,6 +774,15 @@ client6_ifctl(ifname, command)

switch(command) {
case DHCP6CTL_COMMAND_START:
Expand All @@ -85,7 +121,7 @@
free_resources(ifp);
if (client6_start(ifp)) {
dprintf(LOG_NOTICE, FNAME, "failed to restart %s",
@@ -929,7 +945,7 @@ construct_confdata(ifp, ev)
@@ -929,7 +949,7 @@ construct_confdata(ifp, ev)
"failed to create a new event data");
goto fail;
}
Expand All @@ -94,7 +130,73 @@

memset(&iaparam, 0, sizeof(iaparam));
iaparam.iaid = iac->iaid;
@@ -1828,15 +1844,6 @@ client6_recvreply(ifp, dh6, len, optinfo
@@ -1163,27 +1183,33 @@ client6_send(ev)
switch(ev->state) {
case DHCP6S_SOLICIT:
dh6->dh6_msgtype = DH6_SOLICIT;
+ d_printf(LOG_INFO, FNAME, "Sending Solicit");
break;
case DHCP6S_REQUEST:
dh6->dh6_msgtype = DH6_REQUEST;
+ d_printf(LOG_INFO, FNAME, "Sending Request");
break;
case DHCP6S_RENEW:
dh6->dh6_msgtype = DH6_RENEW;
+ d_printf(LOG_INFO, FNAME, "Sending Renew");
break;
case DHCP6S_REBIND:
dh6->dh6_msgtype = DH6_REBIND;
+ d_printf(LOG_INFO, FNAME, "Sending Rebind");
break;
case DHCP6S_RELEASE:
dh6->dh6_msgtype = DH6_RELEASE;
+ d_printf(LOG_INFO, FNAME, "Sending Release");
break;
case DHCP6S_INFOREQ:
dh6->dh6_msgtype = DH6_INFORM_REQ;
+ d_printf(LOG_INFO, FNAME, "Sending Information Request");
break;
default:
dprintf(LOG_ERR, FNAME, "unexpected state");
exit(1); /* XXX */
}
-
+
if (ev->timeouts == 0) {
/*
* A client SHOULD generate a random number that cannot easily
@@ -1721,7 +1747,29 @@ client6_recvreply(ifp, dh6, len, optinfo
dprintf(LOG_INFO, FNAME, "unexpected reply");
return (-1);
}
-
+
+ switch(state)
+ {
+ case DHCP6S_INFOREQ:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received INFOREQ");
+ break;
+ case DHCP6S_REQUEST:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received REQUEST");
+ break;
+ case DHCP6S_RENEW:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received INFO");
+ break;
+ case DHCP6S_REBIND:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received REBIND");
+ break;
+ case DHCP6S_RELEASE:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received RELEASE");
+ break;
+ case DHCP6S_SOLICIT:
+ d_printf(LOG_INFO, FNAME, "dhcp6c Received SOLICIT");
+ break;
+ }
+
/* A Reply message must contain a Server ID option */
if (optinfo->serverID.duid_len == 0) {
dprintf(LOG_INFO, FNAME, "no server ID option");
@@ -1828,15 +1876,6 @@ client6_recvreply(ifp, dh6, len, optinfo
}

/*
Expand All @@ -110,7 +212,7 @@
* Set refresh timer for configuration information specified in
* information-request. If the timer value is specified by the server
* in an information refresh time option, use it; use the protocol
@@ -1888,6 +1895,15 @@ client6_recvreply(ifp, dh6, len, optinfo
@@ -1888,6 +1927,15 @@ client6_recvreply(ifp, dh6, len, optinfo
&optinfo->serverID, ev->authparam);
}

Expand Down
16 changes: 16 additions & 0 deletions net/dhcp6/files/patch-dhcp6c__ia.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- dhcp6c_ia.c.orig 2007-03-21 09:52:55 UTC
+++ dhcp6c_ia.c
@@ -420,7 +420,12 @@ release_all_ia(ifp)
for (ia = TAILQ_FIRST(&iac->iadata); ia; ia = ia_next) {
ia_next = TAILQ_NEXT(ia, link);

- (void)release_ia(ia);
+ if(opt_norelease != 1){
+ d_printf(LOG_INFO, FNAME,"Start address release");
+ (void)release_ia(ia);
+ } else {
+ d_printf(LOG_INFO,FNAME,"Bypassing address release");
+ }

/*
* The client MUST stop using all of the addresses
11 changes: 11 additions & 0 deletions net/dhcp6/files/patch-prefixconf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- prefixconf.c.orig 2007-03-21 09:52:55 UTC
+++ prefixconf.c
@@ -192,7 +192,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp,
/* update the prefix according to pinfo */
sp->prefix.pltime = pinfo->pltime;
sp->prefix.vltime = pinfo->vltime;
- dprintf(LOG_DEBUG, FNAME, "%s a prefix %s/%d pltime=%lu, vltime=%lu",
+ d_printf(LOG_INFO, FNAME, "%s a prefix %s/%d pltime=%lu, vltime=%lu",
spcreate ? "create" : "update",
in6addr2str(&pinfo->addr, 0), pinfo->plen,
pinfo->pltime, pinfo->vltime);