Subject: Re: [PATCH net-next-2.6 09/13] net-caif: add CAIF netdevice

From: Patrick McHardy <[email-masked]>
Date: Tue, 02 Feb 2010 15:17:57 +0100

Sjur Brændeland wrote:
>>> +	if (priv->config.type == CAIF_CHTY_DATAGRAM_LOOP) { +		struct
>>> iphdr *hdr; +		__be32 swap;
>>> +		/* Retrieve IP header. */
>>> +		hdr = ip_hdr(skb);
>>> +		/* Change source and destination address. */
>>> +		swap = hdr->saddr;
>>> +		hdr->saddr = hdr->daddr;
>>> +		hdr->daddr = swap;
>> swap()?
> 
> 
> The modem provides a loopback function for the CAIF link type (CAIF_CHTY_DATAGRAM_LOOP).
> This is useful for testing the physical link between modem and host.
> In this scenario we need to swap src and destination ip address.
> I'll move this to a separate function in next patch set.

There is already a swap() function which you can use.

>>> +static int ipcaif_newlink(struct net *src_net, struct net_device
>>> *dev, +			  struct nlattr *tb[], struct nlattr *data[]) { +	int err;
>>> +	struct chnl_net *caifdev;
>>> +	ASSERT_RTNL();
>>> +	caifdev = netdev_priv(dev);
>>> +	caif_netlink_parms(data, &caifdev->config);
>>> +	err = register_netdevice(dev);
>>> +	if (err) {
>>> +		pr_warning("CAIF: %s(): device rtml registration failed\n", +			 
>>> __func__); +		goto out;
>>> +	}
>>> +	dev_hold(dev);
>> What is this reference used for? You don't have a dellink function,
>> so this looks like a leak. 
> 
> I don't think it leaks because I do dev_put in chnl_net_uninit,
> but you're right - I don't really need this. I'll remove the 
> dev_hold and dev_put completely in next patch-set.

But it wouldn't get released when deleting a link using netlink
I think since without a dellink function I don't see what would
invoke chnl_net_uninit(). Anyways, removing it will fix this :)