1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

bootpd: Add an option to skip modifications to the ARP table.

PR:		30854
Submitted by:	Dan Lukes <dan@obluda.cz>
Reviewed by:	imp (previous version)
MFC after:	1 week
Event:		Waterloo Hackathon 2019
Differential Revision:	https://reviews.freebsd.org/D2581
This commit is contained in:
Mark Johnston 2019-05-21 21:22:43 +00:00
parent 594d1c7235
commit 35131b4616
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348066
3 changed files with 37 additions and 19 deletions

View File

@ -2,7 +2,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd February 10, 2004 .Dd May 21, 2019
.Dt BOOTPD 8 .Dt BOOTPD 8
.Os .Os
.Sh NAME .Sh NAME
@ -103,6 +103,8 @@ option may be used to force standalone or inetd mode respectively
.Sh OPTIONS .Sh OPTIONS
The following options are available: The following options are available:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl a
Skip ARP table modifications.
.It Fl t Ar timeout .It Fl t Ar timeout
Specify the Specify the
.Ar timeout .Ar timeout

View File

@ -143,6 +143,7 @@ struct timeval actualtimeout =
15 * 60L, /* tv_sec */ 15 * 60L, /* tv_sec */
0 /* tv_usec */ 0 /* tv_usec */
}; };
int arpmod = TRUE; /* modify the ARP table */
/* /*
* General * General
@ -266,6 +267,9 @@ main(argc, argv)
break; break;
switch (argv[0][1]) { switch (argv[0][1]) {
case 'a': /* don't modify the ARP table */
arpmod = FALSE;
break;
case 'c': /* chdir_path */ case 'c': /* chdir_path */
if (argv[0][2]) { if (argv[0][2]) {
stmp = &(argv[0][2]); stmp = &(argv[0][2]);
@ -583,8 +587,9 @@ PRIVATE void
usage() usage()
{ {
fprintf(stderr, fprintf(stderr,
"usage: bootpd [-i | -s] [-c chdir-path] [-d level] [-h hostname] [-t timeout]\n"); "usage: bootpd [-a] [-i | -s] [-c chdir-path] [-d level] [-h hostname] [-t timeout]\n");
fprintf(stderr, " [bootptab [dumpfile]]\n"); fprintf(stderr, " [bootptab [dumpfile]]\n");
fprintf(stderr, "\t -a\tdon't modify ARP table\n");
fprintf(stderr, "\t -c n\tset current directory\n"); fprintf(stderr, "\t -c n\tset current directory\n");
fprintf(stderr, "\t -d n\tset debug level\n"); fprintf(stderr, "\t -d n\tset debug level\n");
fprintf(stderr, "\t -h n\tset the hostname to listen on\n"); fprintf(stderr, "\t -h n\tset the hostname to listen on\n");
@ -1067,10 +1072,12 @@ sendreply(forward, dst_override)
if (haf == 0) if (haf == 0)
haf = HTYPE_ETHERNET; haf = HTYPE_ETHERNET;
if (debug > 1) if (arpmod) {
report(LOG_INFO, "setarp %s - %s", if (debug > 1)
inet_ntoa(dst), haddrtoa(ha, len)); report(LOG_INFO, "setarp %s - %s",
setarp(s, &dst, haf, ha, len); inet_ntoa(dst), haddrtoa(ha, len));
setarp(s, &dst, haf, ha, len);
}
} }
if ((forward == 0) && if ((forward == 0) &&

View File

@ -124,6 +124,7 @@ struct timeval actualtimeout =
u_char maxhops = 4; /* Number of hops allowed for requests. */ u_char maxhops = 4; /* Number of hops allowed for requests. */
u_int minwait = 3; /* Number of seconds client must wait before u_int minwait = 3; /* Number of seconds client must wait before
its bootrequest packets are forwarded. */ its bootrequest packets are forwarded. */
int arpmod = TRUE; /* modify the ARP table */
/* /*
* General * General
@ -238,6 +239,9 @@ main(argc, argv)
break; break;
switch (argv[0][1]) { switch (argv[0][1]) {
case 'a': /* don't modify the ARP table */
arpmod = FALSE;
break;
case 'd': /* debug level */ case 'd': /* debug level */
if (argv[0][2]) { if (argv[0][2]) {
stmp = &(argv[0][2]); stmp = &(argv[0][2]);
@ -496,7 +500,8 @@ static void
usage() usage()
{ {
fprintf(stderr, fprintf(stderr,
"usage: bootpgw [-d level] [-i] [-s] [-t timeout] server\n"); "usage: \nbootpgw [-a] [-d level] [-h count] [-i] [-s] [-t timeout] [-w time] server\n");
fprintf(stderr, "\t -a\tdon't modify ARP table\n");
fprintf(stderr, "\t -d n\tset debug level\n"); fprintf(stderr, "\t -d n\tset debug level\n");
fprintf(stderr, "\t -h n\tset max hop count\n"); fprintf(stderr, "\t -h n\tset max hop count\n");
fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n"); fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n");
@ -641,19 +646,23 @@ handle_reply()
send_addr.sin_addr = bp->bp_yiaddr; send_addr.sin_addr = bp->bp_yiaddr;
send_addr.sin_port = htons(bootpc_port); send_addr.sin_port = htons(bootpc_port);
/* Create an ARP cache entry for the client. */ if (arpmod) {
ha = bp->bp_chaddr; /* Create an ARP cache entry for the client. */
len = bp->bp_hlen; ha = bp->bp_chaddr;
if (len > MAXHADDRLEN) len = bp->bp_hlen;
len = MAXHADDRLEN; struct in_addr dst;
haf = (int) bp->bp_htype;
if (haf == 0)
haf = HTYPE_ETHERNET;
if (debug > 1) if (len > MAXHADDRLEN)
report(LOG_INFO, "setarp %s - %s", len = MAXHADDRLEN;
inet_ntoa(bp->bp_yiaddr), haddrtoa(ha, len)); haf = (int) bp->bp_htype;
setarp(s, &bp->bp_yiaddr, haf, ha, len); if (haf == 0)
haf = HTYPE_ETHERNET;
if (debug > 1)
report(LOG_INFO, "setarp %s - %s",
inet_ntoa(dst), haddrtoa(ha, len));
setarp(s, &dst, haf, ha, len);
}
/* Send reply with same size packet as request used. */ /* Send reply with same size packet as request used. */
if (sendto(s, pktbuf, pktlen, 0, if (sendto(s, pktbuf, pktlen, 0,