From owner-freebsd-transport@freebsd.org Wed Jul 20 17:29:31 2016 Return-Path: Delivered-To: freebsd-transport@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7F53B9F7E6 for ; Wed, 20 Jul 2016 17:29:31 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 752D71A9B for ; Wed, 20 Jul 2016 17:29:31 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: by mail-io0-x231.google.com with SMTP id 38so53931472iol.0 for ; Wed, 20 Jul 2016 10:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=wyIC6X34Q7tJP2mgPd2oIj8Wy1k7YjNqFKxkFDByROU=; b=B/Y2+Ovle7tWK+Z3bQk+ofRNVsVFk/L7tIYOXImkXOsUXL1ygwRyni7RflW4jTr0VS +rLls390JNhN1DqgUruHt2ufur6fii0CXRLBrEkvnpAXNsjHWrQsKrfouJJWRbYEgag6 rtYm09lnjdvwpmUvRWeEBH9yf83oi7lVvTYGmr+lXHDrsmmlnn4T/aP3pGgzYG+yupGE Vrdh4ksXva61zQQm7BtJvzTn5jshjvURN3hS/jt+93wRb+By2R6B2rLPeR67/COyB9G1 ApI2k98ZGt7p9mzQmZxuWj/nI1BodxPZNzHbujxNaQGG4gGfvwuhAzCQlmGQ88OTBeV5 SSYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wyIC6X34Q7tJP2mgPd2oIj8Wy1k7YjNqFKxkFDByROU=; b=japIhuie+8Q2NShdilnJztwnzNkgS0dmuC76Kc1mOKgfIwUtE7L6sja/bCAjx82Ij5 YqVb3TGY7LmS5i2qPKixXvU4lstUX/25TljBmI7/AZflX6KS6gOa4qVT50wcHtmmCrR8 dRXpPB9t5F5FzUg8HqGFvFAg5gQpBbQMVUEqBapViGwUxhDHjqP1czm028X1hjaooEjO zrHkZPF2vkkiksFnovPsvlSqSpQ40quAQw3l5gcX2uk5SNgPcNXhVNrm6/xe0ZP8vXcU muXLERtqT1GurE7T4kFaon6e9HPYD6GTlRRp3hhPOliiTv6YaU9YVi4/4V5Xg/6huUja Ka1A== X-Gm-Message-State: ALyK8tLFGVlbe4aNeXimt2m3KMnpxalos9SPgQ7Iw+JW3ajTpE8AIFDC+Jjq92xZo4k1PgAfZ7ROfPlld4891Q== X-Received: by 10.107.129.97 with SMTP id c94mr47032700iod.102.1469035770549; Wed, 20 Jul 2016 10:29:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.200.71 with HTTP; Wed, 20 Jul 2016 10:29:30 -0700 (PDT) From: Ryan Stone Date: Wed, 20 Jul 2016 13:29:30 -0400 Message-ID: Subject: in_broadcast() called for almost every packet in ip_output() To: freebsd-transport@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-transport@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions of transport level network protocols in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 17:29:31 -0000 I've hit a dilemma in a fix I have in review[1]. Currently, in_broadcast() iterates over the ifnet address list without holding any locks. I can pretty easily panic the kernel by constantly adding and removing addresses while passing traffic over the interface. The fix is to acquire the appropriate rlock, but the catch is that according to dtrace, in_broadcast() is called on almost every packet that passes through ip_output(). I'm concerned about adding additional locking operations to the transmit path. Do we actually need to call in_broadcast() so often? It seems silly to check whether we are sending to a broadcast address on a per-packet basis. [1] https://reviews.freebsd.org/D7227