From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Mar 30 09:40:09 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E438F1065674 for ; Tue, 30 Mar 2010 09:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A82748FC15 for ; Tue, 30 Mar 2010 09:40:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o2U9e8YK057965 for ; Tue, 30 Mar 2010 09:40:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o2U9e8Cs057963; Tue, 30 Mar 2010 09:40:08 GMT (envelope-from gnats) Resent-Date: Tue, 30 Mar 2010 09:40:08 GMT Resent-Message-Id: <201003300940.o2U9e8Cs057963@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Gleb Kurtsou Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9640106566C for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/145198: [patch] add verbose option to net-mgmt/choparp X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2010 09:40:09 -0000 >Number: 145198 >Category: ports >Synopsis: [patch] add verbose option to net-mgmt/choparp >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Mar 30 09:40:08 UTC 2010 >Closed-Date: >Last-Modified: >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: >Unformatted: