xfrm: fix gre key endianess
authorTimo Teräs <timo.teras@iki.fi>
Tue, 23 Nov 2010 04:03:45 +0000 (04:03 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 28 Nov 2010 19:22:17 +0000 (11:22 -0800)
fl->fl_gre_key is network byte order contrary to fl->fl_icmp_*.
Make xfrm_flowi_{s|d}port return network byte order values for gre
key too.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h

index 54b283229488f6d8a68d33e209a4274a14a57913..7fa5b005893e0628d0befeb251114fcccbc90dc3 100644 (file)
@@ -806,7 +806,7 @@ __be16 xfrm_flowi_sport(struct flowi *fl)
                port = htons(fl->fl_mh_type);
                break;
        case IPPROTO_GRE:
-               port = htonl(fl->fl_gre_key) >> 16;
+               port = htons(ntohl(fl->fl_gre_key) >> 16);
                break;
        default:
                port = 0;       /*XXX*/
@@ -830,7 +830,7 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
                port = htons(fl->fl_icmp_code);
                break;
        case IPPROTO_GRE:
-               port = htonl(fl->fl_gre_key) & 0xffff;
+               port = htons(ntohl(fl->fl_gre_key) & 0xffff);
                break;
        default:
                port = 0;       /*XXX*/