From owner-freebsd-net@FreeBSD.ORG Tue Feb 19 22:05:58 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 39C71DBE for ; Tue, 19 Feb 2013 22:05:58 +0000 (UTC) (envelope-from vijju.singh@gmail.com) Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com [209.85.215.179]) by mx1.freebsd.org (Postfix) with ESMTP id CAC42A7F for ; Tue, 19 Feb 2013 22:05:57 +0000 (UTC) Received: by mail-ea0-f179.google.com with SMTP id d12so2967281eaa.24 for ; Tue, 19 Feb 2013 14:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=m0c58CJDCb+GJKETKMakaAydZn/7AkqY/7us3R1fDBY=; b=vT6DF/q3pyeBkVbHhQJZxcxD/kDgSmmM4n/NvLEkpsGiR5RofBgJZJ8VPt2ZKAIOZk P+Clw1o2YkoY/NOnJgZx3oJGZuQZtDrFTUVLBR0o0nTSgPVAJ22T/C26u+polP01dnvO 7Xfv/b7e/CeRJOD+w0bEdxKcgU9nsv4D7J7QuicaVCrBIn4YS360LvGLktftbukHMl3b Ayor8ZbFud1mVxJ3Rux45O0YM478hIXk9S78krv4YHeWfu0w/m5XOa20N/LBaZPQVuq1 yGLmfyqn11y5VofuicJzvojfEJ4prhdxvp+dd3PWrMi5ebAQ7og7AfYUrAHLDtJ6O7ip op9w== MIME-Version: 1.0 X-Received: by 10.14.173.196 with SMTP id v44mr61095038eel.29.1361311551348; Tue, 19 Feb 2013 14:05:51 -0800 (PST) Received: by 10.223.161.80 with HTTP; Tue, 19 Feb 2013 14:05:51 -0800 (PST) Date: Tue, 19 Feb 2013 14:05:51 -0800 Message-ID: Subject: Possible optimization in ether_output() From: Vijay Singh To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2013 22:05:58 -0000 Hi, this patch gives a modest performance improvement here @work. Please consider. [/u/vijay/bsd/CODE/cur/sys/net]# svn diff if_ethersubr.c Index: if_ethersubr.c =================================================================== --- if_ethersubr.c (revision 247012) +++ if_ethersubr.c (working copy) @@ -160,6 +160,7 @@ struct pf_mtag *t; int loop_copy = 1; int hlen; /* link layer header length */ + int use_lle_directly = 0; if (ro != NULL) { if (!(m->m_flags & (M_BCAST | M_MCAST))) @@ -184,7 +185,7 @@ #ifdef INET case AF_INET: if (lle != NULL && (lle->la_flags & LLE_VALID)) - memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + use_lle_directly = 1; else error = arpresolve(ifp, rt0, m, dst, edst, &lle); if (error) @@ -222,7 +223,7 @@ #ifdef INET6 case AF_INET6: if (lle != NULL && (lle->la_flags & LLE_VALID)) - memcpy(edst, &lle->ll_addr.mac16, sizeof(edst)); + use_lle_directly = 1; else error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, &lle); if (error) @@ -317,9 +318,13 @@ if (m == NULL) senderr(ENOBUFS); eh = mtod(m, struct ether_header *); - (void)memcpy(&eh->ether_type, &type, - sizeof(eh->ether_type)); - (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); + eh->ether_type = type; + if (use_lle_directly) { + memcpy(eh->ether_dhost, &lle->ll_addr.mac16, + sizeof(eh->ether_dhost)); + } else { + (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); + } if (hdrcmplt) (void)memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost));