kern/165863
Eric van Gyzen
eric at vangyzen.net
Fri Mar 9 15:40:12 UTC 2012
The following reply was made to PR kern/165863; it has been noted by GNATS.
From: Eric van Gyzen <eric at vangyzen.net>
To: Gleb Smirnoff <glebius at FreeBSD.org>
Cc: Eric van Gyzen <eric_van_gyzen at dell.com>, <emaste at FreeBSD.org>,
<bug-followup at FreeBSD.org>, <rysto32 at gmail.com>
Subject: Re: kern/165863
Date: Fri, 9 Mar 2012 09:26:51 -0600
--------------000307010007030804050405
Content-Type: text/plain; charset="KOI8-R"; format=flowed
Content-Transfer-Encoding: 7bit
On 03/09/12 03:20, Gleb Smirnoff wrote:
> Hello, Eric and Ed.
>
> Can you look at this patch? I decided to utilize newer callout API,
> that allows to delegate lock retrieval to the callout subsystem, and
> this makes things simplier. Hope that should work.
>
> Patch is against head.
Doesn't arptimer() still need to acquire the if_afdata_lock in order to
free the entry in the normal case (when the llentry is still in the hash
bucket list)?
With this patch, in_lltable_prefix_free() no longer guarantees that all
the relevant llentries will be freed when it returns. I don't see any
immediate breakage, but it's a notable change in behavior.
> Eric, can you please send me your test programs, that you use to
> reproduce the bug?
Attached is a C program to add and remove the interface address. To
drive traffic, I just used "ping -f".
Thanks for your help.
Eric
--------------000307010007030804050405
Content-Type: text/plain; name="ifconf.set.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ifconf.set.c"
/*-
* Copyright (c) 2012 Dell, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <err.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
int sockfd = -1;
struct ifreq ifr;
struct sockaddr_in * const sin4 = (struct sockaddr_in *) &ifr.ifr_addr;
const char *ifname;
struct in_addr addr, mask, brdaddr;
unsigned int iterations = 0;
bool sigint_received = false;
static void
report(void)
{
printf("%u iterations\n", iterations);
}
static void __dead2
usage()
{
errx(1, "usage: ifconf <ifname> <addr> <mask> <brdaddr> [1]");
}
static void
ifconf(void)
{
bzero(&ifr, sizeof ifr);
strlcpy(ifr.ifr_name, ifname, sizeof ifr.ifr_name);
sin4->sin_family = AF_INET;
sin4->sin_len = sizeof (*sin4);
sin4->sin_addr = addr;
if (ioctl(sockfd, SIOCDIFADDR, &ifr)) {
if (iterations == 0 && errno == EADDRNOTAVAIL) {
// OK, it wasn't there when we started.
} else {
err(1, "SIOCDIFADDR");
}
}
if (ioctl(sockfd, SIOCSIFADDR, &ifr)) {
err(1, "SIOCSIFADDR");
}
#if 0
sin4->sin_addr = mask;
if (ioctl(sockfd, SIOCSIFNETMASK, &ifr)) {
err(1, "SIOCSIFNETMASK");
}
sin4->sin_addr = brdaddr;
if (ioctl(sockfd, SIOCSIFBRDADDR, &ifr)) {
err(1, "SIOCSIFBRDADDR");
}
#endif
}
static void
sigint_handler(int signo __unused)
{
sigint_received = true;
}
int
main(int argc, const char *argv[])
{
if (argc != 5 && argc != 6) {
usage();
}
ifname = argv[1];
if (inet_pton(AF_INET, argv[2], &addr) != 1) {
err(1, "inet_pton(%s)", argv[2]);
}
if (inet_pton(AF_INET, argv[3], &mask) != 1) {
err(1, "inet_pton(%s)", argv[3]);
}
if (inet_pton(AF_INET, argv[4], &brdaddr) != 1) {
err(1, "inet_pton(%s)", argv[4]);
}
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) {
err(1, "socket");
}
if (argc == 6 && atoi(argv[5]) == 1) {
ifconf();
return (0);
}
atexit(report);
signal(SIGINT, sigint_handler);
while (!sigint_received) {
ifconf();
iterations++;
}
putchar('\n');
return (0);
}
--------------000307010007030804050405--
More information about the freebsd-net
mailing list