netlink: implement nla_put_in_addr and nla_put_in6_addr
[cascardo/linux.git] / net / ipv6 / sit.c
index e4cbd57..0e2bb53 100644 (file)
@@ -118,7 +118,7 @@ static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net,
                        return t;
        }
        t = rcu_dereference(sitn->tunnels_wc[0]);
-       if ((t != NULL) && (t->dev->flags & IFF_UP))
+       if (t && (t->dev->flags & IFF_UP))
                return t;
        return NULL;
 }
@@ -251,7 +251,7 @@ static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,
 
        dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
                           ipip6_tunnel_setup);
-       if (dev == NULL)
+       if (!dev)
                return NULL;
 
        dev_net_set(dev, net);
@@ -555,7 +555,7 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
                                skb->dev,
                                iph->daddr,
                                iph->saddr);
-       if (t == NULL)
+       if (!t)
                goto out;
 
        if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
@@ -671,7 +671,7 @@ static int ipip6_rcv(struct sk_buff *skb)
 
        tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
                                     iph->saddr, iph->daddr);
-       if (tunnel != NULL) {
+       if (tunnel) {
                struct pcpu_sw_netstats *tstats;
 
                if (tunnel->parms.iph.protocol != IPPROTO_IPV6 &&
@@ -733,7 +733,7 @@ static int ipip_rcv(struct sk_buff *skb)
        iph = ip_hdr(skb);
        tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
                                     iph->saddr, iph->daddr);
-       if (tunnel != NULL) {
+       if (tunnel) {
                if (tunnel->parms.iph.protocol != IPPROTO_IPIP &&
                    tunnel->parms.iph.protocol != 0)
                        goto drop;
@@ -838,7 +838,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
                if (skb_dst(skb))
                        neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
 
-               if (neigh == NULL) {
+               if (!neigh) {
                        net_dbg_ratelimited("nexthop == NULL\n");
                        goto tx_error;
                }
@@ -867,7 +867,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
                if (skb_dst(skb))
                        neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
 
-               if (neigh == NULL) {
+               if (!neigh) {
                        net_dbg_ratelimited("nexthop == NULL\n");
                        goto tx_error;
                }
@@ -1158,7 +1158,7 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                                break;
                        }
                        t = ipip6_tunnel_locate(net, &p, 0);
-                       if (t == NULL)
+                       if (!t)
                                t = netdev_priv(dev);
                }
 
@@ -1206,7 +1206,7 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                t = ipip6_tunnel_locate(net, &p, cmd == SIOCADDTUNNEL);
 
                if (dev != sitn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {
-                       if (t != NULL) {
+                       if (t) {
                                if (t->dev != dev) {
                                        err = -EEXIST;
                                        break;
@@ -1242,7 +1242,7 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                                goto done;
                        err = -ENOENT;
                        t = ipip6_tunnel_locate(net, &p, 0);
-                       if (t == NULL)
+                       if (!t)
                                goto done;
                        err = -EPERM;
                        if (t == netdev_priv(sitn->fb_tunnel_dev))
@@ -1683,8 +1683,8 @@ static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
        struct ip_tunnel_parm *parm = &tunnel->parms;
 
        if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
-           nla_put_be32(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
-           nla_put_be32(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) ||
+           nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
+           nla_put_in_addr(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) ||
            nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) ||
            nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) ||
            nla_put_u8(skb, IFLA_IPTUN_PMTUDISC,
@@ -1694,10 +1694,10 @@ static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
                goto nla_put_failure;
 
 #ifdef CONFIG_IPV6_SIT_6RD
-       if (nla_put(skb, IFLA_IPTUN_6RD_PREFIX, sizeof(struct in6_addr),
-                   &tunnel->ip6rd.prefix) ||
-           nla_put_be32(skb, IFLA_IPTUN_6RD_RELAY_PREFIX,
-                        tunnel->ip6rd.relay_prefix) ||
+       if (nla_put_in6_addr(skb, IFLA_IPTUN_6RD_PREFIX,
+                            &tunnel->ip6rd.prefix) ||
+           nla_put_in_addr(skb, IFLA_IPTUN_6RD_RELAY_PREFIX,
+                           tunnel->ip6rd.relay_prefix) ||
            nla_put_u16(skb, IFLA_IPTUN_6RD_PREFIXLEN,
                        tunnel->ip6rd.prefixlen) ||
            nla_put_u16(skb, IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
@@ -1795,7 +1795,7 @@ static void __net_exit sit_destroy_tunnels(struct net *net,
                        struct ip_tunnel *t;
 
                        t = rtnl_dereference(sitn->tunnels[prio][h]);
-                       while (t != NULL) {
+                       while (t) {
                                /* If dev is in the same netns, it has already
                                 * been added to the list by the previous loop.
                                 */