From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxim Mikityanskiy Subject: [PATCH 5/7] net/packet: Remove redundant skb->protocol set Date: Mon, 14 Jan 2019 13:19:04 +0000 Message-ID: <20190114131841.1932-6-maximmi@mellanox.com> References: <20190114131841.1932-1-maximmi@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "netdev@vger.kernel.org" , Eran Ben Elisha , Tariq Toukan , Maxim Mikityanskiy To: "David S. Miller" , Saeed Mahameed , Willem de Bruijn , Jason Wang , Eric Dumazet Return-path: Received: from mail-eopbgr00063.outbound.protection.outlook.com ([40.107.0.63]:16205 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726538AbfANNTI (ORCPT ); Mon, 14 Jan 2019 08:19:08 -0500 In-Reply-To: <20190114131841.1932-1-maximmi@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: c72219b75f introduced tpacket_set_protocol that parses the Ethernet L2 header and sets skb->protocol if it's unset. It is no longer needed since the introduction of packet_parse_headers. In case of SOCK_RAW and unset skb->protocol, packet_parse_headers asks the driver to tell the protocol number, and it's implemented for all Ethernet devices. As the old function supported only Ethernet, no functionality is lost. Signed-off-by: Maxim Mikityanskiy --- net/packet/af_packet.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d1d89749a17a..e41bddf3d8bb 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2413,15 +2413,6 @@ static void tpacket_destruct_skb(struct sk_buff *skb= ) sock_wfree(skb); } =20 -static void tpacket_set_protocol(const struct net_device *dev, - struct sk_buff *skb) -{ - if (dev->type =3D=3D ARPHRD_ETHER) { - skb_reset_mac_header(skb); - skb->protocol =3D eth_hdr(skb)->h_proto; - } -} - static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t= len) { if ((vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) && @@ -2492,8 +2483,6 @@ static int tpacket_fill_skb(struct packet_sock *po, s= truct sk_buff *skb, return err; if (!dev_validate_header(dev, skb->data, hdrlen)) return -EINVAL; - if (!skb->protocol) - tpacket_set_protocol(dev, skb); =20 data +=3D hdrlen; to_write -=3D hdrlen; --=20 2.19.1