From owner-freebsd-rc@FreeBSD.ORG Tue Aug 25 23:51:46 2009 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32421106568B for ; Tue, 25 Aug 2009 23:51:46 +0000 (UTC) (envelope-from gleb.kurtsou@gmail.com) Received: from mail-fx0-f210.google.com (mail-fx0-f210.google.com [209.85.220.210]) by mx1.freebsd.org (Postfix) with ESMTP id B0D1C8FC19 for ; Tue, 25 Aug 2009 23:51:45 +0000 (UTC) Received: by fxm6 with SMTP id 6so2396635fxm.43 for ; Tue, 25 Aug 2009 16:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=S7GTAYV2asEID6HFpE7Hjs/kA0FBkQ4qCcTNA92eIiM=; b=J/EcY7Y9FomLOhXegwS4k2kCLLDQOjUQNeKJmAzP1awYrZOXbOeYM3yReSDovA6prI 9JDmRsWdW5FLxK0M1SHcE5bcv4UucVNj1J5ZjgVecONRja+Ux7xRlBYyACg1LuNrNjL2 Y5e/Z299ZPpwe7tuBWx5fqvYvmC2Gcc+eMxd4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=S5vwkigKs+L5xagd8mljJDBDS8CQe360iATM4kL6awvI0QhxNVkksFzKVp14SCst2M KDPjw6SzHBbrGFcFwH4Ujq4ZJRbSTtMlDzPawUEJVdgWBUFFkZ1CPS+8e3G9Hrvr2a1f y+xN32fpZPB2ZzF4Em9txX/6lKzMQpC5lqNXg= Received: by 10.103.84.1 with SMTP id m1mr3098887mul.34.1251242779199; Tue, 25 Aug 2009 16:26:19 -0700 (PDT) Received: from localhost (lan-78-157-90-54.vln.skynet.lt [78.157.90.54]) by mx.google.com with ESMTPS id s11sm3885028mue.41.2009.08.25.16.26.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 25 Aug 2009 16:26:18 -0700 (PDT) Date: Wed, 26 Aug 2009 02:25:58 +0300 From: Gleb Kurtsou To: d@delphij.net Message-ID: <20090825232558.GA1208@tops> References: <200908251907.n7PJ7QiO036868@svn.freebsd.org> <20090825194258.GB1471@tops> <4A9454B2.2040808@delphij.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: <4A9454B2.2040808@delphij.net> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-rc@FreeBSD.org, Xin LI Subject: Re: svn commit: r196550 - in head: etc/defaults etc/rc.d share/man/man5 X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2009 23:51:46 -0000 --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline On (25/08/2009 14:16), Xin LI wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > [Moved to -rc@] > > Hi, Gleb, > > Gleb Kurtsou wrote: > [...] > > Would you please add support for reading pairs from file, that should be > > trivial. I've been using my own rc script for reading static arp entries > > from file but can't find it right now. > > I think it's what 'arp -f' would do. However I didn't found a easy way > to revert its effect, do you have some ideas about it or we need to > teach arp(8) to do that? 'arp -f' is just fine it parses all the options arp has for static entries. I was thinking of something like 'static_arp_files' variable. I've added support for 'arg -d -f' in attached patch (man page part is missing), hope it helps. Thanks, Gleb. > > Cheers, > - -- > Xin LI http://www.delphij.net/ > FreeBSD - The Power to Serve! > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.12 (FreeBSD) > > iEYEARECAAYFAkqUVLIACgkQi+vbBBjt66CzEgCfa9MShg0JzYxKyA2oFWq3prK6 > S7AAn3MGN0QUzRCuPxM2tk5g/hHwvOXR > =DrCH > -----END PGP SIGNATURE----- --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="arp-df.txt" diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 8a3410f..11d1df6 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -101,7 +101,7 @@ static int valid_type(int type); static int nflag; /* no reverse dns lookups */ static char *rifname; -static int expire_time, flags, doing_proxy, proxy_only; +static int expire_time, flags, func, doing_proxy, proxy_only; /* which function we're supposed to do */ #define F_GET 1 @@ -109,23 +109,28 @@ static int expire_time, flags, doing_proxy, proxy_only; #define F_FILESET 3 #define F_REPLACE 4 #define F_DELETE 5 +#define F_FILEDELETE 6 #define SETFUNC(f) { if (func) usage(); func = (f); } int main(int argc, char *argv[]) { - int ch, func = 0; + int ch; int rtn = 0; int aflag = 0; /* do it for all entries */ + func = 0; while ((ch = getopt(argc, argv, "andfsSi:")) != -1) switch(ch) { case 'a': aflag = 1; break; case 'd': - SETFUNC(F_DELETE); + if (func == F_FILESET) + func = F_FILEDELETE; + else + SETFUNC(F_DELETE); break; case 'n': nflag = 1; @@ -137,7 +142,10 @@ main(int argc, char *argv[]) SETFUNC(F_SET); break; case 'f' : - SETFUNC(F_FILESET); + if (func == F_DELETE) + func = F_FILEDELETE; + else + SETFUNC(F_FILESET); break; case 'i': rifname = optarg; @@ -197,6 +205,7 @@ main(int argc, char *argv[]) } break; case F_FILESET: + case F_FILEDELETE: if (argc != 1) usage(); rtn = file(argv[0]); @@ -213,7 +222,7 @@ static int file(char *name) { FILE *fp; - int i, retval; + int i, j, retval; char line[100], arg[5][50], *args[5], *p; if ((fp = fopen(name, "r")) == NULL) @@ -237,8 +246,23 @@ file(char *name) retval = 1; continue; } - if (set(i, args)) - retval = 1; + switch (func) { + case F_FILESET: + if (set(i, args)) + retval = 1; + break; + case F_FILEDELETE: + for (j = 2; j < i; j++) + if (strncmp(args[j], "pub", 3) == 0) { + j = 0; + break; + } + if (delete(args[0], j == 0 ? SIN_PROXY : 0)) + retval = 1; + break; + default: + usage(); + } } fclose(fp); return (retval); @@ -650,11 +674,12 @@ nuke_entry(struct sockaddr_dl *sdl __unused, static void usage(void) { - fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: arp [-n] [-i interface] hostname", " arp [-n] [-i interface] -a", " arp -d hostname [pub]", " arp -d [-i interface] -a", + " arp -d -f filename", " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]", " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]", " arp -f filename"); --EeQfGwPcQSOJBaQU--