ipv4: coding style: comparison for inequality with NULL
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / arp.c
index bca5b9d9b4423225998b75a2d042d4d9203e4d6f..c6e67aa46c32aa78eb7fe9172d90628112e61739 100644 (file)
  *     Interface to generic neighbour cache.
  */
 static u32 arp_hash(const void *pkey, const struct net_device *dev, __u32 *hash_rnd);
+static bool arp_key_eq(const struct neighbour *n, const void *pkey);
 static int arp_constructor(struct neighbour *neigh);
 static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb);
 static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb);
@@ -152,7 +153,9 @@ static const struct neigh_ops arp_direct_ops = {
 struct neigh_table arp_tbl = {
        .family         = AF_INET,
        .key_len        = 4,
+       .protocol       = cpu_to_be16(ETH_P_IP),
        .hash           = arp_hash,
+       .key_eq         = arp_key_eq,
        .constructor    = arp_constructor,
        .proxy_redo     = parp_redo,
        .id             = "arp_cache",
@@ -208,7 +211,12 @@ static u32 arp_hash(const void *pkey,
                    const struct net_device *dev,
                    __u32 *hash_rnd)
 {
-       return arp_hashfn(*(u32 *)pkey, dev, *hash_rnd);
+       return arp_hashfn(pkey, dev, hash_rnd);
+}
+
+static bool arp_key_eq(const struct neighbour *neigh, const void *pkey)
+{
+       return neigh_key_eq32(neigh, pkey);
 }
 
 static int arp_constructor(struct neighbour *neigh)
@@ -220,7 +228,7 @@ static int arp_constructor(struct neighbour *neigh)
 
        rcu_read_lock();
        in_dev = __in_dev_get_rcu(dev);
-       if (in_dev == NULL) {
+       if (!in_dev) {
                rcu_read_unlock();
                return -EINVAL;
        }
@@ -467,7 +475,7 @@ static inline int arp_fwd_pvlan(struct in_device *in_dev,
  */
 
 /*
- *     Create an arp packet. If (dest_hw == NULL), we create a broadcast
+ *     Create an arp packet. If dest_hw is not set, we create a broadcast
  *     message.
  */
 struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
@@ -487,7 +495,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
         */
 
        skb = alloc_skb(arp_hdr_len(dev) + hlen + tlen, GFP_ATOMIC);
-       if (skb == NULL)
+       if (!skb)
                return NULL;
 
        skb_reserve(skb, hlen);
@@ -495,9 +503,9 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
        arp = (struct arphdr *) skb_put(skb, arp_hdr_len(dev));
        skb->dev = dev;
        skb->protocol = htons(ETH_P_ARP);
-       if (src_hw == NULL)
+       if (!src_hw)
                src_hw = dev->dev_addr;
-       if (dest_hw == NULL)
+       if (!dest_hw)
                dest_hw = dev->broadcast;
 
        /*
@@ -561,7 +569,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
                break;
 #endif
        default:
-               if (target_hw != NULL)
+               if (target_hw)
                        memcpy(arp_ptr, target_hw, dev->addr_len);
                else
                        memset(arp_ptr, 0, dev->addr_len);
@@ -606,7 +614,7 @@ void arp_send(int type, int ptype, __be32 dest_ip,
 
        skb = arp_create(type, ptype, dest_ip, dev, src_ip,
                         dest_hw, src_hw, target_hw);
-       if (skb == NULL)
+       if (!skb)
                return;
 
        arp_xmit(skb);
@@ -636,7 +644,7 @@ static int arp_process(struct sk_buff *skb)
         * is ARP'able.
         */
 
-       if (in_dev == NULL)
+       if (!in_dev)
                goto out;
 
        arp = arp_hdr(skb);
@@ -800,7 +808,7 @@ static int arp_process(struct sk_buff *skb)
                is_garp = arp->ar_op == htons(ARPOP_REQUEST) && tip == sip &&
                          inet_addr_type(net, sip) == RTN_UNICAST;
 
-               if (n == NULL &&
+               if (!n &&
                    ((arp->ar_op == htons(ARPOP_REPLY)  &&
                      inet_addr_type(net, sip) == RTN_UNICAST) || is_garp))
                        n = __neigh_lookup(&arp_tbl, &sip, dev, 1);
@@ -892,7 +900,7 @@ out_of_mem:
 
 static int arp_req_set_proxy(struct net *net, struct net_device *dev, int on)
 {
-       if (dev == NULL) {
+       if (!dev) {
                IPV4_DEVCONF_ALL(net, PROXY_ARP) = on;
                return 0;
        }
@@ -918,7 +926,7 @@ static int arp_req_set_public(struct net *net, struct arpreq *r,
                        return -ENODEV;
        }
        if (mask) {
-               if (pneigh_lookup(&arp_tbl, net, &ip, dev, 1) == NULL)
+               if (!pneigh_lookup(&arp_tbl, net, &ip, dev, 1))
                        return -ENOBUFS;
                return 0;
        }
@@ -939,7 +947,7 @@ static int arp_req_set(struct net *net, struct arpreq *r,
        ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
        if (r->arp_flags & ATF_PERM)
                r->arp_flags |= ATF_COM;
-       if (dev == NULL) {
+       if (!dev) {
                struct rtable *rt = ip_route_output(net, ip, 0, RTO_ONLINK, 0);
 
                if (IS_ERR(rt))
@@ -1059,7 +1067,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r,
                return arp_req_delete_public(net, r, dev);
 
        ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
-       if (dev == NULL) {
+       if (!dev) {
                struct rtable *rt = ip_route_output(net, ip, 0, RTO_ONLINK, 0);
                if (IS_ERR(rt))
                        return PTR_ERR(rt);
@@ -1108,7 +1116,7 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)
        if (r.arp_dev[0]) {
                err = -ENODEV;
                dev = __dev_get_by_name(net, r.arp_dev);
-               if (dev == NULL)
+               if (!dev)
                        goto out;
 
                /* Mmmm... It is wrong... ARPHRD_NETROM==0 */