* [pablo-gtp:main 9/11] drivers/net/gtp.c:1011:12: sparse: sparse: incorrect type in assignment (different base types)
@ 2023-10-14 15:46 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-10-14 15:46 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/gtp.git main
head: 230b7c1e9db7fcb2b796845017ce64f35e7430f1
commit: 131a295c85342beb299bbd4dcee11f732fa0d2c3 [9/11] gtp: add helper function to build GTP packets from an IPv4 packet
config: i386-randconfig-062-20231014 (https://download.01.org/0day-ci/archive/20231014/202310142352.LUjQLXaW-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231014/202310142352.LUjQLXaW-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310142352.LUjQLXaW-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/net/gtp.c:1011:12: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] df @@ got unsigned short [usertype] frag_off @@
drivers/net/gtp.c:1011:12: sparse: expected restricted __be16 [usertype] df
drivers/net/gtp.c:1011:12: sparse: got unsigned short [usertype] frag_off
>> drivers/net/gtp.c:1029:24: sparse: sparse: restricted __be16 degrades to integer
>> drivers/net/gtp.c:1073:48: sparse: sparse: incorrect type in argument 6 (different base types) @@ expected unsigned short [usertype] frag_off @@ got restricted __be16 [usertype] frag_off @@
drivers/net/gtp.c:1073:48: sparse: expected unsigned short [usertype] frag_off
drivers/net/gtp.c:1073:48: sparse: got restricted __be16 [usertype] frag_off
drivers/net/gtp.c:1211:45: sparse: sparse: incorrect type in argument 9 (different base types) @@ expected restricted __be32 [usertype] label @@ got unsigned char [addressable] [usertype] tos @@
drivers/net/gtp.c:1211:45: sparse: expected restricted __be32 [usertype] label
drivers/net/gtp.c:1211:45: sparse: got unsigned char [addressable] [usertype] tos
vim +1011 drivers/net/gtp.c
984
985 static int __gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,
986 struct gtp_pktinfo *pktinfo,
987 struct pdp_ctx *pctx, __u8 tos, __u16 frag_off)
988 {
989 struct rtable *rt;
990 struct flowi4 fl4;
991 __be16 df;
992 int mtu;
993
994 rt = ip4_route_output_gtp(&fl4, pctx->sk, pctx->ip4.peer_addr.s_addr,
995 inet_sk(pctx->sk)->inet_saddr);
996 if (IS_ERR(rt)) {
997 netdev_dbg(dev, "no route to SSGN %pI4\n",
998 &pctx->ip4.peer_addr.s_addr);
999 dev->stats.tx_carrier_errors++;
1000 goto err;
1001 }
1002
1003 if (rt->dst.dev == dev) {
1004 netdev_dbg(dev, "circular route to SSGN %pI4\n",
1005 &pctx->ip4.peer_addr.s_addr);
1006 dev->stats.collisions++;
1007 goto err_rt;
1008 }
1009
1010 /* This is similar to tnl_update_pmtu(). */
> 1011 df = frag_off;
1012 if (df) {
1013 mtu = dst_mtu(&rt->dst) - dev->hard_header_len -
1014 sizeof(struct iphdr) - sizeof(struct udphdr);
1015 switch (pctx->gtp_version) {
1016 case GTP_V0:
1017 mtu -= sizeof(struct gtp0_header);
1018 break;
1019 case GTP_V1:
1020 mtu -= sizeof(struct gtp1_header);
1021 break;
1022 }
1023 } else {
1024 mtu = dst_mtu(&rt->dst);
1025 }
1026
1027 skb_dst_update_pmtu_no_confirm(skb, mtu);
1028
> 1029 if (frag_off & htons(IP_DF) &&
1030 ((!skb_is_gso(skb) && skb->len > mtu) ||
1031 (skb_is_gso(skb) && !skb_gso_validate_network_len(skb, mtu)))) {
1032 netdev_dbg(dev, "packet too big, fragmentation needed\n");
1033 icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
1034 htonl(mtu));
1035 goto err_rt;
1036 }
1037
1038 gtp_set_pktinfo_ipv4(pktinfo, pctx->sk, tos, pctx, rt, &fl4, dev);
1039 gtp_push_header(skb, pktinfo);
1040
1041 return 0;
1042 err_rt:
1043 ip_rt_put(rt);
1044 err:
1045 return -EBADMSG;
1046 }
1047
1048 static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,
1049 struct gtp_pktinfo *pktinfo)
1050 {
1051 struct gtp_dev *gtp = netdev_priv(dev);
1052 struct pdp_ctx *pctx;
1053 struct iphdr *iph;
1054 int ret;
1055
1056 /* Read the IP destination address and resolve the PDP context.
1057 * Prepend PDP header with TEI/TID from PDP ctx.
1058 */
1059 iph = ip_hdr(skb);
1060 if (gtp->role == GTP_ROLE_SGSN)
1061 pctx = ipv4_pdp_find(gtp, iph->saddr);
1062 else
1063 pctx = ipv4_pdp_find(gtp, iph->daddr);
1064
1065 if (!pctx) {
1066 netdev_dbg(dev, "no PDP ctx found for %pI4, skip\n",
1067 &iph->daddr);
1068 return -ENOENT;
1069 }
1070 netdev_dbg(dev, "found PDP context %p\n", pctx);
1071
1072 ret = __gtp_build_skb_ip4(skb, dev, pktinfo, pctx,
> 1073 iph->tos, iph->frag_off);
1074 if (ret < 0)
1075 return ret;
1076
1077 netdev_dbg(dev, "gtp -> IP src: %pI4 dst: %pI4\n",
1078 &iph->saddr, &iph->daddr);
1079
1080 return 0;
1081 }
1082
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-14 15:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-14 15:46 [pablo-gtp:main 9/11] drivers/net/gtp.c:1011:12: sparse: sparse: incorrect type in assignment (different base types) kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.