--- zzzz-none-000/linux-3.10.107/net/ipv4/ipmr.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/net/ipv4/ipmr.c 2021-02-04 17:41:59.000000000 +0000 @@ -73,9 +73,7 @@ struct mr_table { struct list_head list; -#ifdef CONFIG_NET_NS - struct net *net; -#endif + possible_net_t net; u32 id; struct sock __rcu *mroute_sk; struct timer_list ipmr_expire_timer; @@ -127,9 +125,9 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id); static void ipmr_free_table(struct mr_table *mrt); -static int ip_mr_forward(struct net *net, struct mr_table *mrt, - struct sk_buff *skb, struct mfc_cache *cache, - int local); +static void ip_mr_forward(struct net *net, struct mr_table *mrt, + struct sk_buff *skb, struct mfc_cache *cache, + int local); static int ipmr_cache_report(struct mr_table *mrt, struct sk_buff *pkt, vifi_t vifi, int assert); static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb, @@ -138,6 +136,9 @@ int cmd); static void mroute_clean_tables(struct mr_table *mrt, bool all); static void ipmr_expire_process(unsigned long arg); +static struct mfc_cache *ipmr_cache_find(struct mr_table *mrt, __be32 origin, + __be32 mcastgrp); +static ipmr_mfc_event_offload_callback_t __rcu ipmr_mfc_event_offload_callback; #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES #define ipmr_for_each_table(mrt, net) \ @@ -184,6 +185,7 @@ case FR_ACT_UNREACHABLE: return -ENETUNREACH; case FR_ACT_PROHIBIT: + case FR_ACT_POLICY_FAILED: return -EACCES; case FR_ACT_BLACKHOLE: default: @@ -191,7 +193,7 @@ } mrt = ipmr_get_table(rule->fr_net, rule->table); - if (mrt == NULL) + if (!mrt) return -EAGAIN; res->mrt = mrt; return 0; @@ -227,6 +229,78 @@ return 0; } +/* ipmr_sync_entry_update() + * Call the registered offload callback to report an update to a multicast + * route entry. The callback receives the list of destination interfaces and + * the interface count + */ +static void ipmr_sync_entry_update(struct mr_table *mrt, + struct mfc_cache *cache) +{ + int vifi, dest_if_count = 0; + u32 dest_dev[MAXVIFS]; + __be32 origin; + __be32 group; + ipmr_mfc_event_offload_callback_t offload_update_cb_f; + + memset(dest_dev, 0, sizeof(dest_dev)); + + origin = cache->mfc_origin; + group = cache->mfc_mcastgrp; + + read_lock(&mrt_lock); + for (vifi = 0; vifi < cache->mfc_un.res.maxvif; vifi++) { + if (!((cache->mfc_un.res.ttls[vifi] > 0) && + (cache->mfc_un.res.ttls[vifi] < 255))) { + continue; + } + if (dest_if_count == MAXVIFS) { + read_unlock(&mrt_lock); + return; + } + + if (!VIF_EXISTS(mrt, vifi)) { + read_unlock(&mrt_lock); + return; + } + dest_dev[dest_if_count] = mrt->vif_table[vifi].dev->ifindex; + dest_if_count++; + } + read_unlock(&mrt_lock); + + rcu_read_lock(); + offload_update_cb_f = rcu_dereference(ipmr_mfc_event_offload_callback); + + if (!offload_update_cb_f) { + rcu_read_unlock(); + return; + } + + offload_update_cb_f(group, origin, dest_if_count, dest_dev, + IPMR_MFC_EVENT_UPDATE); + rcu_read_unlock(); +} + +/* ipmr_sync_entry_delete() + * Call the registered offload callback to inform of a multicast route entry + * delete event + */ +static void ipmr_sync_entry_delete(u32 origin, u32 group) +{ + ipmr_mfc_event_offload_callback_t offload_update_cb_f; + + rcu_read_lock(); + offload_update_cb_f = rcu_dereference(ipmr_mfc_event_offload_callback); + + if (!offload_update_cb_f) { + rcu_read_unlock(); + return; + } + + offload_update_cb_f(group, origin, 0, NULL, IPMR_MFC_EVENT_DELETE); + rcu_read_unlock(); +} + static const struct fib_rules_ops __net_initconst ipmr_rules_ops_template = { .family = RTNL_FAMILY_IPMR, .rule_size = sizeof(struct ipmr_rule), @@ -235,13 +309,156 @@ .match = ipmr_rule_match, .configure = ipmr_rule_configure, .compare = ipmr_rule_compare, - .default_pref = fib_default_rule_pref, .fill = ipmr_rule_fill, .nlgroup = RTNLGRP_IPV4_RULE, .policy = ipmr_rule_policy, .owner = THIS_MODULE, }; +/* ipmr_register_mfc_event_offload_callback() + * Register the IPv4 Multicast update offload callback with IPMR + */ +bool ipmr_register_mfc_event_offload_callback( + ipmr_mfc_event_offload_callback_t mfc_offload_cb) +{ + ipmr_mfc_event_offload_callback_t offload_update_cb_f; + + rcu_read_lock(); + offload_update_cb_f = rcu_dereference(ipmr_mfc_event_offload_callback); + + if (offload_update_cb_f) { + rcu_read_unlock(); + return false; + } + + rcu_assign_pointer(ipmr_mfc_event_offload_callback, mfc_offload_cb); + rcu_read_unlock(); + return true; +} +EXPORT_SYMBOL(ipmr_register_mfc_event_offload_callback); + +/* ipmr_unregister_mfc_event_offload_callback() + * De-register the IPv4 Multicast update offload callback with IPMR + */ +void ipmr_unregister_mfc_event_offload_callback(void) +{ + rcu_read_lock(); + rcu_assign_pointer(ipmr_mfc_event_offload_callback, NULL); + rcu_read_unlock(); +} +EXPORT_SYMBOL(ipmr_unregister_mfc_event_offload_callback); + +/* ipmr_find_mfc_entry() + * Returns destination interface list for a particular multicast flow, and + * the number of interfaces in the list + */ +int ipmr_find_mfc_entry(struct net *net, __be32 origin, __be32 group, + u32 max_dest_cnt, u32 dest_dev[]) +{ + int vifi, dest_if_count = 0; + struct mr_table *mrt; + struct mfc_cache *cache; + + mrt = ipmr_get_table(net, RT_TABLE_DEFAULT); + if (!mrt) + return -ENOENT; + + rcu_read_lock(); + cache = ipmr_cache_find(mrt, origin, group); + if (!cache) { + rcu_read_unlock(); + return -ENOENT; + } + + read_lock(&mrt_lock); + for (vifi = 0; vifi < cache->mfc_un.res.maxvif; vifi++) { + if (!((cache->mfc_un.res.ttls[vifi] > 0) && + (cache->mfc_un.res.ttls[vifi] < 255))) { + continue; + } + + /* We have another valid destination interface entry. Check if + * the number of the destination interfaces for the route is + * exceeding the size of the array given to us + */ + if (dest_if_count == max_dest_cnt) { + read_unlock(&mrt_lock); + rcu_read_unlock(); + return -EINVAL; + } + + if (!VIF_EXISTS(mrt, vifi)) { + read_unlock(&mrt_lock); + rcu_read_unlock(); + return -EINVAL; + } + + dest_dev[dest_if_count] = mrt->vif_table[vifi].dev->ifindex; + dest_if_count++; + } + read_unlock(&mrt_lock); + rcu_read_unlock(); + + return dest_if_count; +} +EXPORT_SYMBOL(ipmr_find_mfc_entry); + +/* ipmr_mfc_stats_update() + * Update the MFC/VIF statistics for offloaded flows + */ +int ipmr_mfc_stats_update(struct net *net, __be32 origin, __be32 group, + u64 pkts_in, u64 bytes_in, + u64 pkts_out, u64 bytes_out) +{ + int vif, vifi; + struct mr_table *mrt; + struct mfc_cache *cache; + + mrt = ipmr_get_table(net, RT_TABLE_DEFAULT); + if (!mrt) + return -ENOENT; + + rcu_read_lock(); + cache = ipmr_cache_find(mrt, origin, group); + if (!cache) { + rcu_read_unlock(); + return -ENOENT; + } + + vif = cache->mfc_parent; + + read_lock(&mrt_lock); + if (!VIF_EXISTS(mrt, vif)) { + read_unlock(&mrt_lock); + rcu_read_unlock(); + return -EINVAL; + } + + mrt->vif_table[vif].pkt_in += pkts_in; + mrt->vif_table[vif].bytes_in += bytes_in; + cache->mfc_un.res.pkt += pkts_out; + cache->mfc_un.res.bytes += bytes_out; + + for (vifi = cache->mfc_un.res.minvif; + vifi < cache->mfc_un.res.maxvif; vifi++) { + if ((cache->mfc_un.res.ttls[vifi] > 0) && + (cache->mfc_un.res.ttls[vifi] < 255)) { + if (!VIF_EXISTS(mrt, vifi)) { + read_unlock(&mrt_lock); + rcu_read_unlock(); + return -EINVAL; + } + mrt->vif_table[vifi].pkt_out += pkts_out; + mrt->vif_table[vifi].bytes_out += bytes_out; + } + } + read_unlock(&mrt_lock); + rcu_read_unlock(); + + return 0; +} +EXPORT_SYMBOL(ipmr_mfc_stats_update); + static int __net_init ipmr_rules_init(struct net *net) { struct fib_rules_ops *ops; @@ -255,7 +472,7 @@ INIT_LIST_HEAD(&net->ipv4.mr_tables); mrt = ipmr_new_table(net, RT_TABLE_DEFAULT); - if (mrt == NULL) { + if (!mrt) { err = -ENOMEM; goto err1; } @@ -268,7 +485,7 @@ return 0; err2: - kfree(mrt); + ipmr_free_table(mrt); err1: fib_rules_unregister(ops); return err; @@ -278,11 +495,13 @@ { struct mr_table *mrt, *next; + rtnl_lock(); list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list) { list_del(&mrt->list); ipmr_free_table(mrt); } fib_rules_unregister(net->ipv4.mr_rules_ops); + rtnl_unlock(); } #else #define ipmr_for_each_table(mrt, net) \ @@ -308,7 +527,10 @@ static void __net_exit ipmr_rules_exit(struct net *net) { + rtnl_lock(); ipmr_free_table(net->ipv4.mrt); + net->ipv4.mrt = NULL; + rtnl_unlock(); } #endif @@ -318,11 +540,11 @@ unsigned int i; mrt = ipmr_get_table(net, id); - if (mrt != NULL) + if (mrt) return mrt; mrt = kzalloc(sizeof(*mrt), GFP_KERNEL); - if (mrt == NULL) + if (!mrt) return NULL; write_pnet(&mrt->net, net); mrt->id = id; @@ -424,10 +646,11 @@ dev->flags |= IFF_MULTICAST; in_dev = __in_dev_get_rtnl(dev); - if (in_dev == NULL) + if (!in_dev) goto failure; ipv4_devconf_setall(in_dev); + neigh_parms_data_state_setall(in_dev->arp_parms); IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0; if (dev_open(dev)) @@ -438,10 +661,6 @@ return dev; failure: - /* allow the register to be completed before unregistering. */ - rtnl_unlock(); - rtnl_lock(); - unregister_netdevice(dev); return NULL; } @@ -454,7 +673,7 @@ struct mr_table *mrt; struct flowi4 fl4 = { .flowi4_oif = dev->ifindex, - .flowi4_iif = skb->skb_iif, + .flowi4_iif = skb->skb_iif ? : LOOPBACK_IFINDEX, .flowi4_mark = skb->mark, }; int err; @@ -474,8 +693,14 @@ return NETDEV_TX_OK; } +static int reg_vif_get_iflink(const struct net_device *dev) +{ + return 0; +} + static const struct net_device_ops reg_vif_netdev_ops = { .ndo_start_xmit = reg_vif_xmit, + .ndo_get_iflink = reg_vif_get_iflink, }; static void reg_vif_setup(struct net_device *dev) @@ -483,7 +708,7 @@ dev->type = ARPHRD_PIMREG; dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; dev->flags = IFF_NOARP; - dev->netdev_ops = ®_vif_netdev_ops, + dev->netdev_ops = ®_vif_netdev_ops; dev->destructor = free_netdev; dev->features |= NETIF_F_NETNS_LOCAL; } @@ -499,9 +724,9 @@ else sprintf(name, "pimreg%u", mrt->id); - dev = alloc_netdev(0, name, reg_vif_setup); + dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, reg_vif_setup); - if (dev == NULL) + if (!dev) return NULL; dev_net_set(dev, net); @@ -510,7 +735,6 @@ free_netdev(dev); return NULL; } - dev->iflink = 0; rcu_read_lock(); in_dev = __in_dev_get_rcu(dev); @@ -520,6 +744,7 @@ } ipv4_devconf_setall(in_dev); + neigh_parms_data_state_setall(in_dev->arp_parms); IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0; rcu_read_unlock(); @@ -531,10 +756,6 @@ return dev; failure: - /* allow the register to be completed before unregistering. */ - rtnl_unlock(); - rtnl_lock(); - unregister_netdevice(dev); return NULL; } @@ -757,7 +978,7 @@ case 0: if (vifc->vifc_flags == VIFF_USE_IFINDEX) { dev = dev_get_by_index(net, vifc->vifc_lcl_ifindex); - if (dev && __in_dev_get_rtnl(dev) == NULL) { + if (dev && !__in_dev_get_rtnl(dev)) { dev_put(dev); return -EADDRNOTAVAIL; } @@ -801,7 +1022,7 @@ v->pkt_out = 0; v->link = dev->ifindex; if (v->flags & (VIFF_TUNNEL | VIFF_REGISTER)) - v->link = dev->iflink; + v->link = dev_get_iflink(dev); /* And finish update writing critical data */ write_lock_bh(&mrt_lock); @@ -985,7 +1206,7 @@ /* Copy the IP header */ - skb->network_header = skb->tail; + skb_set_network_header(skb, skb->len); skb_put(skb, ihl); skb_copy_to_linear_data(skb, pkt->data, ihl); ip_hdr(skb)->protocol = 0; /* Flag to the kernel this is a route add */ @@ -1005,7 +1226,7 @@ rcu_read_lock(); mroute_sk = rcu_dereference(mrt->mroute_sk); - if (mroute_sk == NULL) { + if (!mroute_sk) { rcu_read_unlock(); kfree_skb(skb); return -EINVAL; @@ -1105,6 +1326,7 @@ { int line; struct mfc_cache *c, *next; + u32 origin, group; line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr); @@ -1112,9 +1334,14 @@ if (c->mfc_origin == mfc->mfcc_origin.s_addr && c->mfc_mcastgrp == mfc->mfcc_mcastgrp.s_addr && (parent == -1 || parent == c->mfc_parent)) { + origin = c->mfc_origin; + group = c->mfc_mcastgrp; list_del_rcu(&c->list); mroute_netlink_event(mrt, c, RTM_DELROUTE); ipmr_cache_free(c); + + /* Inform offload modules of the delete event */ + ipmr_sync_entry_delete(origin, group); return 0; } } @@ -1150,6 +1377,9 @@ c->mfc_flags |= MFC_STATIC; write_unlock_bh(&mrt_lock); mroute_netlink_event(mrt, c, RTM_NEWROUTE); + + /* Inform offload modules of the update event */ + ipmr_sync_entry_update(mrt, c); return 0; } @@ -1158,7 +1388,7 @@ return -EINVAL; c = ipmr_cache_alloc(); - if (c == NULL) + if (!c) return -ENOMEM; c->mfc_origin = mfc->mfcc_origin.s_addr; @@ -1206,6 +1436,7 @@ int i; LIST_HEAD(list); struct mfc_cache *c, *next; + u32 origin, group; /* Shut down all active vif entries */ @@ -1222,9 +1453,14 @@ list_for_each_entry_safe(c, next, &mrt->mfc_cache_array[i], list) { if (!all && (c->mfc_flags & MFC_STATIC)) continue; + origin = c->mfc_origin; + group = c->mfc_mcastgrp; list_del_rcu(&c->list); mroute_netlink_event(mrt, c, RTM_DELROUTE); ipmr_cache_free(c); + + /* Inform offload modules of the delete event */ + ipmr_sync_entry_delete(origin, group); } } @@ -1281,7 +1517,7 @@ return -EOPNOTSUPP; mrt = ipmr_get_table(net, raw_sk(sk)->ipmr_table ? : RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return -ENOENT; if (optname != MRT_INIT) { @@ -1444,7 +1680,7 @@ return -EOPNOTSUPP; mrt = ipmr_get_table(net, raw_sk(sk)->ipmr_table ? : RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return -ENOENT; if (optname != MRT_VERSION && @@ -1490,7 +1726,7 @@ struct mr_table *mrt; mrt = ipmr_get_table(net, raw_sk(sk)->ipmr_table ? : RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return -ENOENT; switch (cmd) { @@ -1564,7 +1800,7 @@ struct mr_table *mrt; mrt = ipmr_get_table(net, raw_sk(sk)->ipmr_table ? : RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return -ENOENT; switch (cmd) { @@ -1615,7 +1851,7 @@ static int ipmr_device_event(struct notifier_block *this, unsigned long event, void *ptr) { - struct net_device *dev = ptr; + struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net *net = dev_net(dev); struct mr_table *mrt; struct vif_device *v; @@ -1645,7 +1881,8 @@ * important for multicast video. */ -static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) +static void ip_encap(struct net *net, struct sk_buff *skb, + __be32 saddr, __be32 daddr) { struct iphdr *iph; const struct iphdr *old_iph = ip_hdr(skb); @@ -1664,24 +1901,25 @@ iph->protocol = IPPROTO_IPIP; iph->ihl = 5; iph->tot_len = htons(skb->len); - ip_select_ident(skb, NULL); + ip_select_ident(net, skb, NULL); ip_send_check(iph); memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); nf_reset(skb); } -static inline int ipmr_forward_finish(struct sk_buff *skb) +static inline int ipmr_forward_finish(struct net *net, struct sock *sk, + struct sk_buff *skb) { struct ip_options *opt = &(IPCB(skb)->opt); - IP_INC_STATS(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS); - IP_ADD_STATS(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len); + IP_INC_STATS(net, IPSTATS_MIB_OUTFORWDATAGRAMS); + IP_ADD_STATS(net, IPSTATS_MIB_OUTOCTETS, skb->len); if (unlikely(opt->optlen)) ip_forward_options(skb); - return dst_output(skb); + return dst_output(net, sk, skb); } /* @@ -1698,7 +1936,7 @@ struct flowi4 fl4; int encap = 0; - if (vif->dev == NULL) + if (!vif->dev) goto out_free; #ifdef CONFIG_IP_PIMSM @@ -1738,7 +1976,7 @@ * to blackhole. */ - IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); + IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); ip_rt_put(rt); goto out_free; } @@ -1761,7 +1999,7 @@ * What do we do with netfilter? -- RR */ if (vif->flags & VIFF_TUNNEL) { - ip_encap(skb, vif->local, vif->remote); + ip_encap(net, skb, vif->local, vif->remote); /* FIXME: extra output firewall step used to be here. --RR */ vif->dev->stats.tx_packets++; vif->dev->stats.tx_bytes += skb->len; @@ -1780,7 +2018,8 @@ * not mrouter) cannot join to more than one interface - it will * result in receiving multiple packets. */ - NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, skb, skb->dev, dev, + NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, + net, NULL, skb, skb->dev, dev, ipmr_forward_finish); return; @@ -1801,9 +2040,9 @@ /* "local" means that we should preserve one skb (for local delivery) */ -static int ip_mr_forward(struct net *net, struct mr_table *mrt, - struct sk_buff *skb, struct mfc_cache *cache, - int local) +static void ip_mr_forward(struct net *net, struct mr_table *mrt, + struct sk_buff *skb, struct mfc_cache *cache, + int local) { int psend = -1; int vif, ct; @@ -1909,14 +2148,13 @@ ipmr_queue_xmit(net, mrt, skb2, cache, psend); } else { ipmr_queue_xmit(net, mrt, skb, cache, psend); - return 0; + return; } } dont_forward: if (!local) kfree_skb(skb); - return 0; } static struct mr_table *ipmr_rt_fib_lookup(struct net *net, struct sk_buff *skb) @@ -1990,7 +2228,7 @@ /* already under rcu_read_lock() */ cache = ipmr_cache_find(mrt, ip_hdr(skb)->saddr, ip_hdr(skb)->daddr); - if (cache == NULL) { + if (!cache) { int vif = ipmr_find_vif(mrt, skb->dev); if (vif >= 0) @@ -2001,13 +2239,13 @@ /* * No usable cache entry */ - if (cache == NULL) { + if (!cache) { int vif; if (local) { struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); ip_local_deliver(skb); - if (skb2 == NULL) + if (!skb2) return -ENOBUFS; skb = skb2; } @@ -2066,7 +2304,7 @@ reg_dev = mrt->vif_table[mrt->mroute_reg_vif_num].dev; read_unlock(&mrt_lock); - if (reg_dev == NULL) + if (!reg_dev) return 1; skb->mac_header = skb->network_header; @@ -2074,9 +2312,8 @@ skb_reset_network_header(skb); skb->protocol = htons(ETH_P_IP); skb->ip_summed = CHECKSUM_NONE; - skb->pkt_type = PACKET_HOST; - skb_tunnel_rx(skb, reg_dev); + skb_tunnel_rx(skb, reg_dev, dev_net(reg_dev)); netif_rx(skb); @@ -2197,18 +2434,18 @@ int err; mrt = ipmr_get_table(net, RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return -ENOENT; rcu_read_lock(); cache = ipmr_cache_find(mrt, saddr, daddr); - if (cache == NULL && skb->dev) { + if (!cache && skb->dev) { int vif = ipmr_find_vif(mrt, skb->dev); if (vif >= 0) cache = ipmr_cache_find_any(mrt, daddr, vif); } - if (cache == NULL) { + if (!cache) { struct sk_buff *skb2; struct iphdr *iph; struct net_device *dev; @@ -2267,7 +2504,7 @@ int err; nlh = nlmsg_put(skb, portid, seq, cmd, sizeof(*rtm), flags); - if (nlh == NULL) + if (!nlh) return -EMSGSIZE; rtm = nlmsg_data(nlh); @@ -2286,15 +2523,16 @@ rtm->rtm_protocol = RTPROT_MROUTED; rtm->rtm_flags = 0; - if (nla_put_be32(skb, RTA_SRC, c->mfc_origin) || - nla_put_be32(skb, RTA_DST, c->mfc_mcastgrp)) + if (nla_put_in_addr(skb, RTA_SRC, c->mfc_origin) || + nla_put_in_addr(skb, RTA_DST, c->mfc_mcastgrp)) goto nla_put_failure; err = __ipmr_fill_mroute(mrt, skb, c, rtm); /* do not break the dump if cache is unresolved */ if (err < 0 && err != -ENOENT) goto nla_put_failure; - return nlmsg_end(skb, nlh); + nlmsg_end(skb, nlh); + return 0; nla_put_failure: nlmsg_cancel(skb, nlh); @@ -2331,7 +2569,7 @@ skb = nlmsg_new(mroute_msgsize(mfc->mfc_parent >= MAXVIFS, mrt->maxvif), GFP_ATOMIC); - if (skb == NULL) + if (!skb) goto errout; err = ipmr_fill_mroute(mrt, skb, 0, 0, mfc, cmd, 0); @@ -2446,7 +2684,7 @@ struct mr_table *mrt; mrt = ipmr_get_table(net, RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return ERR_PTR(-ENOENT); iter->mrt = mrt; @@ -2493,7 +2731,7 @@ const char *name = vif->dev ? vif->dev->name : "none"; seq_printf(seq, - "%2Zd %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n", + "%2Zd %-10s %8llu %7llu %8llu %7llu %05X %08X %08X\n", vif - mrt->vif_table, name, vif->bytes_in, vif->pkt_in, vif->bytes_out, vif->pkt_out, @@ -2565,7 +2803,7 @@ struct mr_table *mrt; mrt = ipmr_get_table(net, RT_TABLE_DEFAULT); - if (mrt == NULL) + if (!mrt) return ERR_PTR(-ENOENT); it->mrt = mrt;