{"id":640,"url":"http://patchwork.ozlabs.org/api/1.0/patches/640/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20080919152448.GB29403@ghostprotocols.net>","date":"2008-09-19T15:24:48","name":": net: Use hton[sl]() was Re: [PATCH 10/14] Phonet: Phonet datagram transport protocol","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"980a007db11d08b97d1ca51e523aae684963606f","submitter":{"id":313,"url":"http://patchwork.ozlabs.org/api/1.0/people/313/?format=json","name":"Arnaldo Carvalho de Melo","email":"acme@redhat.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.0/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20080919152448.GB29403@ghostprotocols.net/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/640/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Received":["from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id 9C473DE1A2\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 20 Sep 2008 01:35:14 +1000 (EST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752887AbYISPe4 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 19 Sep 2008 11:34:56 -0400","(majordomo@vger.kernel.org) by vger.kernel.org id S1752768AbYISPez\n\t(ORCPT <rfc822; netdev-outgoing>); Fri, 19 Sep 2008 11:34:55 -0400","from mx2.redhat.com ([66.187.237.31]:41181 \"EHLO mx2.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751299AbYISPex (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tFri, 19 Sep 2008 11:34:53 -0400","from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com\n\t[172.16.27.26])\n\tby mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m8JFXHVi013383;\n\tFri, 19 Sep 2008 11:33:37 -0400","from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199])\n\tby int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id\n\tm8JFX5OU028142; Fri, 19 Sep 2008 11:33:06 -0400","from doppio.ghostprotocols.net (vpn-12-129.rdu.redhat.com\n\t[10.11.12.129])\n\tby ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m8JFX2ZL017959;\n\tFri, 19 Sep 2008 11:33:04 -0400","by doppio.ghostprotocols.net (Postfix, from userid 500)\n\tid 779C21C009B; Fri, 19 Sep 2008 12:24:48 -0300 (BRT)"],"Date":"Fri, 19 Sep 2008 12:24:48 -0300","From":"Arnaldo Carvalho de Melo <acme@redhat.com>","To":"\"David S. Miller\" <davem@davemloft.net>","Cc":"=?iso-8859-1?Q?R=E9mi?= Denis-Courmont \n\t<remi.denis-courmont@nokia.com>, netdev@vger.kernel.org","Subject":"[PATCH]: net: Use hton[sl]() was Re: [PATCH 10/14] Phonet: Phonet\n\tdatagram transport protocol","Message-ID":"<20080919152448.GB29403@ghostprotocols.net>","Mail-Followup-To":"Arnaldo Carvalho de Melo <acme@redhat.com>,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\t=?iso-8859-1?Q?R=E9mi?= Denis-Courmont\n\t<remi.denis-courmont@nokia.com>, netdev@vger.kernel.org","References":"<200809161757.38571.remi.denis-courmont@nokia.com>\n\t<1221577694-4513-10-git-send-email-remi.denis-courmont@nokia.com>\n\t<20080916170644.GM8702@ghostprotocols.net>\n\t<200809190933.33638.remi.denis-courmont@nokia.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<200809190933.33638.remi.denis-courmont@nokia.com>","X-Url":"http://oops.ghostprotocols.net:81/blog","User-Agent":"Mutt/1.5.18 (2008-05-17)","X-Scanned-By":"MIMEDefang 2.58 on 172.16.27.26","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Em Fri, Sep 19, 2008 at 09:33:33AM +0300, Rémi Denis-Courmont escreveu:\n> On Tuesday 16 September 2008 20:06:44 ext Arnaldo Carvalho de Melo, you wrote:\n> > > +\tph->robj = pn_obj(dst);\n> > > +\tph->sobj = pn_obj(src);\n> > > +\n> > > +\tskb->protocol = __constant_htons(ETH_P_PHONET);\n> >\n> > No need for __constant_htons(CONSTANT), htons will do the right thing\n> > and the code will be shorter, clearer.\n> \n> Ok. There are quite many of these in net/ though... is that reserved for \n> switch/case only?\n\nNope, they should only be used when initializing static variables.\n\nDavid, the following patch converts what is in net-next-2.6 net/ now:\n\n\ncommit 8e64a880d1f8a3df44648e0109f22a22322acc56\nAuthor: Arnaldo Carvalho de Melo <acme@redhat.com>\nDate:   Fri Sep 19 11:34:45 2008 -0300\n\n    net: Use hton[sl]() instead of __constant_hton[sl]() where applicable\n    \n    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>","diff":"diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c\nindex 97688cd..8883e9c 100644\n--- a/net/8021q/vlan_dev.c\n+++ b/net/8021q/vlan_dev.c\n@@ -48,7 +48,7 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)\n \n \tswitch (veth->h_vlan_encapsulated_proto) {\n #ifdef CONFIG_INET\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \n \t\t/* TODO:  Confirm this will work with VLAN headers... */\n \t\treturn arp_find(veth->h_dest, skb);\ndiff --git a/net/atm/br2684.c b/net/atm/br2684.c\nindex 8d9a6f1..280de48 100644\n--- a/net/atm/br2684.c\n+++ b/net/atm/br2684.c\n@@ -375,11 +375,11 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)\n \t\t\tif (memcmp\n \t\t\t    (skb->data + 6, ethertype_ipv6,\n \t\t\t     sizeof(ethertype_ipv6)) == 0)\n-\t\t\t\tskb->protocol = __constant_htons(ETH_P_IPV6);\n+\t\t\t\tskb->protocol = htons(ETH_P_IPV6);\n \t\t\telse if (memcmp\n \t\t\t\t (skb->data + 6, ethertype_ipv4,\n \t\t\t\t  sizeof(ethertype_ipv4)) == 0)\n-\t\t\t\tskb->protocol = __constant_htons(ETH_P_IP);\n+\t\t\t\tskb->protocol = htons(ETH_P_IP);\n \t\t\telse\n \t\t\t\tgoto error;\n \t\t\tskb_pull(skb, sizeof(llc_oui_ipv4));\n@@ -404,9 +404,9 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)\n \t\t\tskb_reset_network_header(skb);\n \t\t\tiph = ip_hdr(skb);\n \t\t\tif (iph->version == 4)\n-\t\t\t\tskb->protocol = __constant_htons(ETH_P_IP);\n+\t\t\t\tskb->protocol = htons(ETH_P_IP);\n \t\t\telse if (iph->version == 6)\n-\t\t\t\tskb->protocol = __constant_htons(ETH_P_IPV6);\n+\t\t\t\tskb->protocol = htons(ETH_P_IPV6);\n \t\t\telse\n \t\t\t\tgoto error;\n \t\t\tskb->pkt_type = PACKET_HOST;\ndiff --git a/net/core/dev.c b/net/core/dev.c\nindex f48d1b2..fdfc4b6 100644\n--- a/net/core/dev.c\n+++ b/net/core/dev.c\n@@ -1675,13 +1675,13 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)\n \t}\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\tip_proto = ip_hdr(skb)->protocol;\n \t\taddr1 = ip_hdr(skb)->saddr;\n \t\taddr2 = ip_hdr(skb)->daddr;\n \t\tihl = ip_hdr(skb)->ihl;\n \t\tbreak;\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\tip_proto = ipv6_hdr(skb)->nexthdr;\n \t\taddr1 = ipv6_hdr(skb)->saddr.s6_addr32[3];\n \t\taddr2 = ipv6_hdr(skb)->daddr.s6_addr32[3];\ndiff --git a/net/ethernet/eth.c b/net/ethernet/eth.c\nindex a80839b..647a9ed 100644\n--- a/net/ethernet/eth.c\n+++ b/net/ethernet/eth.c\n@@ -129,7 +129,7 @@ int eth_rebuild_header(struct sk_buff *skb)\n \n \tswitch (eth->h_proto) {\n #ifdef CONFIG_INET\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn arp_find(eth->h_dest, skb);\n #endif\n \tdefault:\ndiff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c\nindex ece748d..958abf3 100644\n--- a/net/ipv4/ipvs/ip_vs_core.c\n+++ b/net/ipv4/ipvs/ip_vs_core.c\n@@ -938,7 +938,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb,\n \n \tEnterFunction(11);\n \n-\taf = (skb->protocol == __constant_htons(ETH_P_IP)) ? AF_INET : AF_INET6;\n+\taf = (skb->protocol == htons(ETH_P_IP)) ? AF_INET : AF_INET6;\n \n \tif (skb->ipvs_property)\n \t\treturn NF_ACCEPT;\n@@ -1258,7 +1258,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb,\n \tstruct ip_vs_conn *cp;\n \tint ret, restart, af;\n \n-\taf = (skb->protocol == __constant_htons(ETH_P_IP)) ? AF_INET : AF_INET6;\n+\taf = (skb->protocol == htons(ETH_P_IP)) ? AF_INET : AF_INET6;\n \n \tip_vs_fill_iphdr(af, skb_network_header(skb), &iph);\n \ndiff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c\nindex 17c7b09..64ce3d3 100644\n--- a/net/ipv6/ip6_tunnel.c\n+++ b/net/ipv6/ip6_tunnel.c\n@@ -1050,10 +1050,10 @@ ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)\n \t}\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\tret = ip4ip6_tnl_xmit(skb, dev);\n \t\tbreak;\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\tret = ip6ip6_tnl_xmit(skb, dev);\n \t\tbreak;\n \tdefault:\ndiff --git a/net/mac80211/wme.c b/net/mac80211/wme.c\nindex 7229e95..5966b9f 100644\n--- a/net/mac80211/wme.c\n+++ b/net/mac80211/wme.c\n@@ -39,7 +39,7 @@ static unsigned int classify_1d(struct sk_buff *skb)\n \t\treturn skb->priority - 256;\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\tdscp = ip_hdr(skb)->tos & 0xfc;\n \t\tbreak;\n \ndiff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c\nindex 8f63a1a..0ebaff6 100644\n--- a/net/sched/cls_flow.c\n+++ b/net/sched/cls_flow.c\n@@ -67,9 +67,9 @@ static inline u32 addr_fold(void *addr)\n static u32 flow_get_src(const struct sk_buff *skb)\n {\n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn ntohl(ip_hdr(skb)->saddr);\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\treturn ntohl(ipv6_hdr(skb)->saddr.s6_addr32[3]);\n \tdefault:\n \t\treturn addr_fold(skb->sk);\n@@ -79,9 +79,9 @@ static u32 flow_get_src(const struct sk_buff *skb)\n static u32 flow_get_dst(const struct sk_buff *skb)\n {\n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn ntohl(ip_hdr(skb)->daddr);\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\treturn ntohl(ipv6_hdr(skb)->daddr.s6_addr32[3]);\n \tdefault:\n \t\treturn addr_fold(skb->dst) ^ (__force u16)skb->protocol;\n@@ -91,9 +91,9 @@ static u32 flow_get_dst(const struct sk_buff *skb)\n static u32 flow_get_proto(const struct sk_buff *skb)\n {\n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn ip_hdr(skb)->protocol;\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\treturn ipv6_hdr(skb)->nexthdr;\n \tdefault:\n \t\treturn 0;\n@@ -120,7 +120,7 @@ static u32 flow_get_proto_src(const struct sk_buff *skb)\n \tu32 res = 0;\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP): {\n+\tcase htons(ETH_P_IP): {\n \t\tstruct iphdr *iph = ip_hdr(skb);\n \n \t\tif (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&\n@@ -128,7 +128,7 @@ static u32 flow_get_proto_src(const struct sk_buff *skb)\n \t\t\tres = ntohs(*(__be16 *)((void *)iph + iph->ihl * 4));\n \t\tbreak;\n \t}\n-\tcase __constant_htons(ETH_P_IPV6): {\n+\tcase htons(ETH_P_IPV6): {\n \t\tstruct ipv6hdr *iph = ipv6_hdr(skb);\n \n \t\tif (has_ports(iph->nexthdr))\n@@ -147,7 +147,7 @@ static u32 flow_get_proto_dst(const struct sk_buff *skb)\n \tu32 res = 0;\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP): {\n+\tcase htons(ETH_P_IP): {\n \t\tstruct iphdr *iph = ip_hdr(skb);\n \n \t\tif (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&\n@@ -155,7 +155,7 @@ static u32 flow_get_proto_dst(const struct sk_buff *skb)\n \t\t\tres = ntohs(*(__be16 *)((void *)iph + iph->ihl * 4 + 2));\n \t\tbreak;\n \t}\n-\tcase __constant_htons(ETH_P_IPV6): {\n+\tcase htons(ETH_P_IPV6): {\n \t\tstruct ipv6hdr *iph = ipv6_hdr(skb);\n \n \t\tif (has_ports(iph->nexthdr))\n@@ -213,9 +213,9 @@ static u32 flow_get_nfct(const struct sk_buff *skb)\n static u32 flow_get_nfct_src(const struct sk_buff *skb)\n {\n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn ntohl(CTTUPLE(skb, src.u3.ip));\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\treturn ntohl(CTTUPLE(skb, src.u3.ip6[3]));\n \t}\n fallback:\n@@ -225,9 +225,9 @@ fallback:\n static u32 flow_get_nfct_dst(const struct sk_buff *skb)\n {\n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\treturn ntohl(CTTUPLE(skb, dst.u3.ip));\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\treturn ntohl(CTTUPLE(skb, dst.u3.ip6[3]));\n \t}\n fallback:\ndiff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c\nindex edd1298..ba43aab 100644\n--- a/net/sched/sch_dsmark.c\n+++ b/net/sched/sch_dsmark.c\n@@ -202,7 +202,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)\n \n \tif (p->set_tc_index) {\n \t\tswitch (skb->protocol) {\n-\t\tcase __constant_htons(ETH_P_IP):\n+\t\tcase htons(ETH_P_IP):\n \t\t\tif (skb_cow_head(skb, sizeof(struct iphdr)))\n \t\t\t\tgoto drop;\n \n@@ -210,7 +210,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)\n \t\t\t\t& ~INET_ECN_MASK;\n \t\t\tbreak;\n \n-\t\tcase __constant_htons(ETH_P_IPV6):\n+\t\tcase htons(ETH_P_IPV6):\n \t\t\tif (skb_cow_head(skb, sizeof(struct ipv6hdr)))\n \t\t\t\tgoto drop;\n \n@@ -289,11 +289,11 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)\n \tpr_debug(\"index %d->%d\\n\", skb->tc_index, index);\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t\tipv4_change_dsfield(ip_hdr(skb), p->mask[index],\n \t\t\t\t    p->value[index]);\n \t\t\tbreak;\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t\tipv6_change_dsfield(ipv6_hdr(skb), p->mask[index],\n \t\t\t\t    p->value[index]);\n \t\t\tbreak;\ndiff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c\nindex 6e041d1..fe1508e 100644\n--- a/net/sched/sch_sfq.c\n+++ b/net/sched/sch_sfq.c\n@@ -119,7 +119,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)\n \tu32 h, h2;\n \n \tswitch (skb->protocol) {\n-\tcase __constant_htons(ETH_P_IP):\n+\tcase htons(ETH_P_IP):\n \t{\n \t\tconst struct iphdr *iph = ip_hdr(skb);\n \t\th = iph->daddr;\n@@ -134,7 +134,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)\n \t\t\th2 ^= *(((u32*)iph) + iph->ihl);\n \t\tbreak;\n \t}\n-\tcase __constant_htons(ETH_P_IPV6):\n+\tcase htons(ETH_P_IPV6):\n \t{\n \t\tstruct ipv6hdr *iph = ipv6_hdr(skb);\n \t\th = iph->daddr.s6_addr32[3];\ndiff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c\nindex e55427f..5c1954d 100644\n--- a/net/sunrpc/xprtrdma/rpc_rdma.c\n+++ b/net/sunrpc/xprtrdma/rpc_rdma.c\n@@ -769,7 +769,7 @@ repost:\n \t/* check for expected message types */\n \t/* The order of some of these tests is important. */\n \tswitch (headerp->rm_type) {\n-\tcase __constant_htonl(RDMA_MSG):\n+\tcase htonl(RDMA_MSG):\n \t\t/* never expect read chunks */\n \t\t/* never expect reply chunks (two ways to check) */\n \t\t/* never expect write chunks without having offered RDMA */\n@@ -802,7 +802,7 @@ repost:\n \t\trpcrdma_inline_fixup(rqst, (char *)iptr, rep->rr_len);\n \t\tbreak;\n \n-\tcase __constant_htonl(RDMA_NOMSG):\n+\tcase htonl(RDMA_NOMSG):\n \t\t/* never expect read or write chunks, always reply chunks */\n \t\tif (headerp->rm_body.rm_chunks[0] != xdr_zero ||\n \t\t    headerp->rm_body.rm_chunks[1] != xdr_zero ||\n","prefixes":[]}