Skip to content

Commit

Permalink
CAIF: Fix IPv6 support in receive path for GPRS/3G
Browse files Browse the repository at this point in the history
Checks version field of IP in the receive path for GPRS/3G data
and appropriately sets the value of skb->protocol.

Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kumar Sanghvi authored and David S. Miller committed Jan 11, 2011
1 parent 545ecdc commit d7b92af
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion net/caif/chnl_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
struct chnl_net *priv = container_of(layr, struct chnl_net, chnl);
int pktlen;
int err = 0;
const u8 *ip_version;
u8 buf;

priv = container_of(layr, struct chnl_net, chnl);

Expand All @@ -90,7 +92,21 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
* send the packet to the net stack.
*/
skb->dev = priv->netdev;
skb->protocol = htons(ETH_P_IP);

/* check the version of IP */
ip_version = skb_header_pointer(skb, 0, 1, &buf);
if (!ip_version)
return -EINVAL;
switch (*ip_version >> 4) {
case 4:
skb->protocol = htons(ETH_P_IP);
break;
case 6:
skb->protocol = htons(ETH_P_IPV6);
break;
default:
return -EINVAL;
}

/* If we change the header in loop mode, the checksum is corrupted. */
if (priv->conn_req.protocol == CAIFPROTO_DATAGRAM_LOOP)
Expand Down

0 comments on commit d7b92af

Please sign in to comment.