From: kbuild test robot <lkp@intel.com>
To: Roopa Prabhu <roopa@cumulusnetworks.com>
Cc: kbuild-all@01.org, davem@davemloft.net, netdev@vger.kernel.org,
dsa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
idosch@mellanox.com
Subject: Re: [PATCH net-next v2 1/3] ipv4: support sport and dport in RTM_GETROUTE
Date: Mon, 7 May 2018 13:49:57 +0800 [thread overview]
Message-ID: <201805071252.BAvgeC2B%fengguang.wu@intel.com> (raw)
In-Reply-To: <1525654787-21990-2-git-send-email-roopa@cumulusnetworks.com>
Hi Roopa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Roopa-Prabhu/fib-rule-selftest/20180507-094538
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
net/ipv4/route.c:1271:31: sparse: expression using sizeof(void)
net/ipv4/route.c:1271:31: sparse: expression using sizeof(void)
net/ipv4/route.c:1274:16: sparse: expression using sizeof(void)
net/ipv4/route.c:1274:16: sparse: expression using sizeof(void)
net/ipv4/route.c:1295:15: sparse: expression using sizeof(void)
net/ipv4/route.c:688:38: sparse: expression using sizeof(void)
net/ipv4/route.c:712:38: sparse: expression using sizeof(void)
net/ipv4/route.c:782:46: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [unsigned] [usertype] key @@ got ed int [unsigned] [usertype] key @@
net/ipv4/route.c:782:46: expected unsigned int [unsigned] [usertype] key
net/ipv4/route.c:782:46: got restricted __be32 [usertype] new_gw
>> net/ipv4/route.c:2695:29: sparse: incorrect type in initializer (different base types) @@ expected int [signed] p @@ got restint [signed] p @@
net/ipv4/route.c:2695:29: expected int [signed] p
net/ipv4/route.c:2695:29: got restricted __be16
>> net/ipv4/route.c:2700:15: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] <noident> @@ got 6 [usertype] <noident> @@
net/ipv4/route.c:2700:15: expected restricted __be16 [usertype] <noident>
net/ipv4/route.c:2700:15: got int [signed] p
>> net/ipv4/route.c:2816:27: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] len @@ got 6 [usertype] len @@
net/ipv4/route.c:2816:27: expected restricted __be16 [usertype] len
net/ipv4/route.c:2816:27: got unsigned long
vim +2695 net/ipv4/route.c
2692
2693 static int nla_get_port(struct nlattr *attr, __be16 *port)
2694 {
> 2695 int p = nla_get_be16(attr);
2696
2697 if (p <= 0 || p >= 0xffff)
2698 return -EINVAL;
2699
> 2700 *port = p;
2701 return 0;
2702 }
2703
2704 static int inet_rtm_getroute_reply(struct sk_buff *in_skb, struct nlmsghdr *nlh,
2705 __be32 dst, __be32 src, struct flowi4 *fl4,
2706 struct rtable *rt, struct fib_result *res)
2707 {
2708 struct net *net = sock_net(in_skb->sk);
2709 struct rtmsg *rtm = nlmsg_data(nlh);
2710 u32 table_id = RT_TABLE_MAIN;
2711 struct sk_buff *skb;
2712 int err = 0;
2713
2714 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
2715 if (!skb) {
2716 err = -ENOMEM;
2717 return err;
2718 }
2719
2720 if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
2721 table_id = res->table ? res->table->tb_id : 0;
2722
2723 if (rtm->rtm_flags & RTM_F_FIB_MATCH)
2724 err = fib_dump_info(skb, NETLINK_CB(in_skb).portid,
2725 nlh->nlmsg_seq, RTM_NEWROUTE, table_id,
2726 rt->rt_type, res->prefix, res->prefixlen,
2727 fl4->flowi4_tos, res->fi, 0);
2728 else
2729 err = rt_fill_info(net, dst, src, rt, table_id,
2730 fl4, skb, NETLINK_CB(in_skb).portid,
2731 nlh->nlmsg_seq);
2732 if (err < 0)
2733 goto errout;
2734
2735 return rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
2736
2737 errout:
2738 kfree_skb(skb);
2739 return err;
2740 }
2741
2742 static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
2743 struct netlink_ext_ack *extack)
2744 {
2745 struct net *net = sock_net(in_skb->sk);
2746 struct nlattr *tb[RTA_MAX+1];
2747 __be16 sport = 0, dport = 0;
2748 struct fib_result res = {};
2749 struct rtable *rt = NULL;
2750 struct sk_buff *skb;
2751 struct rtmsg *rtm;
2752 struct flowi4 fl4;
2753 struct iphdr *iph;
2754 struct udphdr *udph;
2755 __be32 dst = 0;
2756 __be32 src = 0;
2757 kuid_t uid;
2758 u32 iif;
2759 int err;
2760 int mark;
2761
2762 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy,
2763 extack);
2764 if (err < 0)
2765 return err;
2766
2767 rtm = nlmsg_data(nlh);
2768
2769 skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
2770 if (!skb) {
2771 err = -ENOBUFS;
2772 return err;
2773 }
2774
2775 /* Reserve room for dummy headers, this skb can pass
2776 through good chunk of routing engine.
2777 */
2778 skb_reset_mac_header(skb);
2779 skb_reset_network_header(skb);
2780
2781 src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0;
2782 dst = tb[RTA_DST] ? nla_get_in_addr(tb[RTA_DST]) : 0;
2783 iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0;
2784 mark = tb[RTA_MARK] ? nla_get_u32(tb[RTA_MARK]) : 0;
2785 if (tb[RTA_UID])
2786 uid = make_kuid(current_user_ns(), nla_get_u32(tb[RTA_UID]));
2787 else
2788 uid = (iif ? INVALID_UID : current_uid());
2789 if (tb[RTA_SPORT]) {
2790 err = nla_get_port(tb[RTA_SPORT], &sport);
2791 if (err)
2792 goto errout_free;
2793 }
2794
2795 if (tb[RTA_DPORT]) {
2796 err = nla_get_port(tb[RTA_DPORT], &dport);
2797 if (err)
2798 goto errout_free;
2799 }
2800
2801 skb->protocol = htons(ETH_P_IP);
2802 iph = skb_put(skb, sizeof(struct iphdr));
2803 iph->protocol = IPPROTO_UDP;
2804 iph->saddr = src;
2805 iph->daddr = dst;
2806 iph->version = 0x4;
2807 iph->frag_off = 0;
2808
2809 if (sport || dport) {
2810 iph->ihl = 0x5;
2811 skb_set_transport_header(skb, skb->len);
2812
2813 udph = skb_put(skb, sizeof(struct udphdr));
2814 udph->dest = dport;
2815 udph->source = sport;
> 2816 udph->len = sizeof(struct udphdr);
2817 udph->check = 0;
2818 }
2819
2820 memset(&fl4, 0, sizeof(fl4));
2821 fl4.daddr = dst;
2822 fl4.saddr = src;
2823 fl4.flowi4_tos = rtm->rtm_tos;
2824 fl4.flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0;
2825 fl4.flowi4_mark = mark;
2826 fl4.flowi4_uid = uid;
2827 if (sport)
2828 fl4.fl4_sport = sport;
2829 if (dport)
2830 fl4.fl4_dport = dport;
2831 fl4.flowi4_proto = IPPROTO_UDP;
2832
2833 rcu_read_lock();
2834
2835 if (iif) {
2836 struct net_device *dev;
2837
2838 dev = dev_get_by_index_rcu(net, iif);
2839 if (!dev) {
2840 err = -ENODEV;
2841 goto errout_rcu;
2842 }
2843
2844 fl4.flowi4_iif = iif; /* for rt_fill_info */
2845 skb->protocol = htons(ETH_P_IP);
2846 skb->dev = dev;
2847 skb->mark = mark;
2848 err = ip_route_input_rcu(skb, dst, src, rtm->rtm_tos,
2849 dev, &res);
2850
2851 rt = skb_rtable(skb);
2852 if (err == 0 && rt->dst.error)
2853 err = -rt->dst.error;
2854 } else {
2855 fl4.flowi4_iif = LOOPBACK_IFINDEX;
2856 rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb);
2857 err = 0;
2858 if (IS_ERR(rt))
2859 err = PTR_ERR(rt);
2860 else
2861 skb_dst_set(skb, &rt->dst);
2862 }
2863
2864 if (err)
2865 goto errout_rcu;
2866
2867 if (rtm->rtm_flags & RTM_F_NOTIFY)
2868 rt->rt_flags |= RTCF_NOTIFY;
2869
2870 if (rtm->rtm_flags & RTM_F_FIB_MATCH) {
2871 if (!res.fi) {
2872 err = fib_props[res.type].error;
2873 if (!err)
2874 err = -EHOSTUNREACH;
2875 goto errout_rcu;
2876 }
2877 }
2878
2879 err = inet_rtm_getroute_reply(in_skb, nlh, dst, src, &fl4, rt, &res);
2880 if (err < 0)
2881 goto errout_rcu;
2882
2883 rcu_read_unlock();
2884
2885 errout_free:
2886 kfree_skb(skb);
2887 return err;
2888 errout_rcu:
2889 rcu_read_unlock();
2890 goto errout_free;
2891 }
2892
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
next prev parent reply other threads:[~2018-05-07 5:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 0:59 [PATCH net-next v2 0/3] fib rule selftest Roopa Prabhu
2018-05-07 0:59 ` [PATCH net-next v2 1/3] ipv4: support sport and dport in RTM_GETROUTE Roopa Prabhu
2018-05-07 1:46 ` David Ahern
2018-05-07 14:42 ` Roopa Prabhu
2018-05-07 5:49 ` kbuild test robot [this message]
2018-05-07 0:59 ` [PATCH net-next v2 2/3] ipv6: " Roopa Prabhu
2018-05-07 1:46 ` David Ahern
2018-05-07 6:23 ` kbuild test robot
2018-05-07 0:59 ` [PATCH net-next v2 3/3] selftests: net: initial fib rule tests Roopa Prabhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201805071252.BAvgeC2B%fengguang.wu@intel.com \
--to=lkp@intel.com \
--cc=davem@davemloft.net \
--cc=dsa@cumulusnetworks.com \
--cc=idosch@mellanox.com \
--cc=kbuild-all@01.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox