From nobody@FreeBSD.org  Tue Mar 30 09:33:05 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E9640106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Mar 2010 09:33:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id BF94B8FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Mar 2010 09:33:05 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2U9X5hX060043
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 30 Mar 2010 09:33:05 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2U9X53e060042;
	Tue, 30 Mar 2010 09:33:05 GMT
	(envelope-from nobody)
Message-Id: <201003300933.o2U9X53e060042@www.freebsd.org>
Date: Tue, 30 Mar 2010 09:33:05 GMT
From: Gleb Kurtsou <gk@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] add verbose option to net-mgmt/choparp
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145198
>Category:       ports
>Synopsis:       [patch] add verbose option to net-mgmt/choparp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    nork
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 30 09:40:08 UTC 2010
>Closed-Date:    Tue May 04 14:04:01 UTC 2010
>Last-Modified:  Tue May  4 14:10:01 UTC 2010
>Originator:     Gleb Kurtsou
>Release:        
>Organization:
>Environment:
FreeBSD tops 9.0-CURRENT FreeBSD 9.0-CURRENT #19 r205158+38fe7c2-dirty: Thu Mar 18 15:48:13 EET 2010     root@tops:/usr/obj/freebsd-src/local/sys/TOPS  amd64
>Description:
By default choparp prints warning on gratuitous ARP packets.
Print warning only if -v option given
Add another type gratuitous ARP used by windows: packet containing zero sender ip
>How-To-Repeat:

>Fix:
Copy attached patch to /usr/ports/net-mgmt/choparp/files
Rebuild, install

Patch attached with submission follows:

--- choparp.c.orig	2010-03-17 21:22:44.000000000 +0200
+++ choparp.c	2010-03-17 21:20:52.421965709 +0200
@@ -76,6 +76,7 @@
 
 struct cidr *targets = NULL, *excludes = NULL;
 u_char	target_mac[ETHER_ADDR_LEN];	/* target MAC address */
+int verbose = 0;
 
 /*
    ARP filter program
@@ -241,7 +242,13 @@
 	return(0);
     }
     if (ntohl(*(u_int32_t *)(arp->arp_tpa)) == ntohl(*(u_int32_t *)(arp->arp_spa))) {
-	fprintf(stderr,"checkarp: WARNING: sender equal dest.\n");
+	if (verbose != 0)
+	    fprintf(stderr,"checkarp: WARNING: sender equal dest.\n");
+	return(0);
+    }
+    if (0 == ntohl(*(u_int32_t *)(arp->arp_spa))) {
+	if (verbose != 0)
+	    fprintf(stderr,"checkarp: WARNING: zero sender address.\n");
 	return(0);
     }
     target_ip = ntohl(*(u_int32_t *)(arp->arp_tpa));
@@ -376,13 +383,13 @@
 
 void
 usage(void){
-    fprintf(stderr,"usage: choparp if_name mac_addr [-]addr/mask...\n");
+    fprintf(stderr,"usage: choparp [-v] if_name mac_addr [-]addr/mask...\n");
     exit(-1);
 }
 
 int
 main(int argc, char **argv){
-    int	fd;
+    int	ch, fd;
     char *buf, *ifname;
     struct cidr **targets_tail = &targets, **excludes_tail = &excludes;
 #define APPEND(LIST,ADDR,MASK) \
@@ -395,13 +402,24 @@
     } while (0)
     size_t buflen;
 
-    if (argc < 4)
+    while ((ch = getopt(argc, argv, "v")) != -1)
+        switch (ch) {
+        case 'v':
+            verbose++;
+            break;
+        default:
+            usage();
+        }
+    argc -= optind;
+    argv += optind;
+
+    if (argc < 3)
 	usage();
 
-    ifname = argv[1];
-    if (setmac(argv[2], ifname))
+    ifname = argv[0];
+    if (setmac(argv[1], ifname))
 	usage();
-    argv += 3; argc -= 3;
+    argv += 2; argc -= 2;
 
     while (argc > 0) {
 	u_int32_t addr, mask = ~0;
--- choparp.8.orig	2010-03-17 21:22:44.000000000 +0200
+++ choparp.8	2010-03-17 21:20:05.461772794 +0200
@@ -35,6 +35,7 @@
 .Nd cheap and omitted proxy ARP
 .Sh SYNOPSIS
 .Nm choparp
+.Op Fl v
 .Ar if_name mac_addr
 .Oo Fl Oc Ns Ar net_addr Ns
 .Op / Ns Ar net_mask
@@ -90,6 +91,9 @@
 by preceding them with
 .Fl
 .Pp
+.Fl v
+option enables verbose mode, showing warning for invalid ARP packets.
+.Pp
 .Nm choparp
 uses the Berkeley Packet Filter
 .Nm bpf(4)


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->nork 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Mar 30 09:40:17 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145198 
State-Changed-From-To: open->closed 
State-Changed-By: nork 
State-Changed-When: Tue May 4 14:03:43 UTC 2010 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145198 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/145198: commit references a PR
Date: Tue,  4 May 2010 14:03:43 +0000 (UTC)

 nork        2010-05-04 14:03:14 UTC
 
   FreeBSD ports repository
 
   Modified files:
     net-mgmt/choparp     Makefile 
     net-mgmt/choparp/files patch-choparp.8 patch-choparp.c 
   Log:
   Add verbose option to print warning only, and another type gratuitous
   ARP used by windows: packet containing zero sender ip.
   
   PR:             ports/145198
   Submitted by:   Gleb Kurtsou
   
   Revision  Changes    Path
   1.17      +1 -1      ports/net-mgmt/choparp/Makefile
   1.2       +11 -7     ports/net-mgmt/choparp/files/patch-choparp.8
   1.4       +67 -8     ports/net-mgmt/choparp/files/patch-choparp.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
