From patchwork Wed Aug 31 16:32:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 664599 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sPWG20pk5z9sxS for ; Thu, 1 Sep 2016 02:35:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AW9ZDv9K; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030381AbcHaQdI (ORCPT ); Wed, 31 Aug 2016 12:33:08 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:32938 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935817AbcHaQcw (ORCPT ); Wed, 31 Aug 2016 12:32:52 -0400 Received: by mail-pf0-f196.google.com with SMTP id i6so2993864pfe.0 for ; Wed, 31 Aug 2016 09:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=esYE2Wo2FcBACbfpDxigUR33NbPRNoPG2FhlGpNz1oA=; b=AW9ZDv9KwQqPe4xHn+mevto0hM61wzroVX5uUIsAiySdOHfLOFpBL/24hArrHndsg4 H68y39Vpvijhy20wyiVgLf4peiZB3HLE6xktLkjzeqYXaesbUSOkiQC2iYXBfWAt9MKx Ihmx/NDsUPS8JtII7MOx2jFCBay/6rfcfcUjmwQ5+2Aht+/jjU3ss9DGko/IR6LX9HtE 1gNvrIxhnuWL87TCYPrzmrgNHy0p4rHuL7QfG9W/Fv2Ew9Y9tmOyEShCcNYi4d7IcCR6 QxiKbEDSVs+Q6blMZIkcD15lS8mUH7g1VE4BLtAVJ/KxuFDHyefOWGFR/ICskVgaVsrX lM5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=esYE2Wo2FcBACbfpDxigUR33NbPRNoPG2FhlGpNz1oA=; b=G5jF+iNlrOTSifUP+q9z28uwM4eYK6gZUwkQ0lu8buDPtpDs7BgJJpc7Y10rV9Xg+N kKT9ZozKT9zR7AvjoVFwTJ/d4oIRP7m4v3HJc6BRLRbDErM6VaXZZFhTAC8JpccTtBti YFKUh9VbqEFKkt5Q5jIPCVgOCZF7ViulXSFP5a3CEMjZ2HP7jStrcKQr91UdhQEzCeX2 C/BfXW5o3wimQi2YF+J2kZmFxH3fRvg3JfNwG0uPpZG1JVwIzwyo1199gfRjMCY8A5lD /PvvfjSqjy5FITmZv0CQ0L6EynQEIUw/cOk2APCeTOjLUaNGqduw1Vv5PJKQ+MZG99Q4 atTQ== X-Gm-Message-State: AE9vXwP7frR6yUfF4W9Wwml+QAdzLFR8etguOwM5V6Ig+ilcX3vvbkey12ONLa5VWVqGbw== X-Received: by 10.98.33.147 with SMTP id o19mr18473960pfj.8.1472661171825; Wed, 31 Aug 2016 09:32:51 -0700 (PDT) Received: from centos-gvrose.Lightfleet.com (c-73-25-61-32.hsd1.wa.comcast.net. [73.25.61.32]) by smtp.gmail.com with ESMTPSA id 9sm851565pfo.74.2016.08.31.09.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Aug 2016 09:32:51 -0700 (PDT) From: Greg Rose X-Google-Original-From: Greg Rose To: netdev@vger.kernel.org Cc: Greg Rose Subject: [PATCH] net/ethernet: Use ether_addr_copy rather than memcpy Date: Wed, 31 Aug 2016 09:32:48 -0700 Message-Id: <1472661168-22396-1-git-send-email-grose@lightfleet.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I'm not sure why this hasn't been done before because it seems obvious, so maybe there is some reason that memcpy is used instead of ether_addr_copy in this code. But let's try this anyway. Change memcpy to ether_addr_copy. Signed-off-by: Greg Rose --- net/ethernet/eth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 66dff5e..cbcdb97 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -95,10 +95,10 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, if (!saddr) saddr = dev->dev_addr; - memcpy(eth->h_source, saddr, ETH_ALEN); + ether_addr_copy(eth->h_source, saddr); if (daddr) { - memcpy(eth->h_dest, daddr, ETH_ALEN); + ether_addr_copy(eth->h_dest, daddr); return ETH_HLEN; } @@ -211,7 +211,7 @@ EXPORT_SYMBOL(eth_type_trans); int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr) { const struct ethhdr *eth = eth_hdr(skb); - memcpy(haddr, eth->h_source, ETH_ALEN); + ether_addr_copy(haddr, eth->h_source); return ETH_ALEN; } EXPORT_SYMBOL(eth_header_parse); @@ -236,8 +236,8 @@ int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh, __be16 return -1; eth->h_proto = type; - memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); - memcpy(eth->h_dest, neigh->ha, ETH_ALEN); + ether_addr_copy(eth->h_source, dev->dev_addr); + ether_addr_copy(eth->h_dest, neigh->ha); hh->hh_len = ETH_HLEN; return 0; } @@ -255,8 +255,8 @@ void eth_header_cache_update(struct hh_cache *hh, const struct net_device *dev, const unsigned char *haddr) { - memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), - haddr, ETH_ALEN); + ether_addr_copy(((u8 *)hh->hh_data) + + HH_DATA_OFF(sizeof(struct ethhdr)), haddr); } EXPORT_SYMBOL(eth_header_cache_update); @@ -286,7 +286,7 @@ void eth_commit_mac_addr_change(struct net_device *dev, void *p) { struct sockaddr *addr = p; - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + ether_addr_copy(dev->dev_addr, addr->sa_data); } EXPORT_SYMBOL(eth_commit_mac_addr_change);