Hi Paolo,

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/Paolo-Abeni/TC-refactor-TC_ACT_REDIRECT-action/20180716-011055
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> net/sched/act_mirred.c:195:17: sparse: dubious: x | !y
   net/sched/act_mirred.c:260:23: sparse: expression using sizeof(void)
   net/sched/act_mirred.c:260:23: sparse: expression using sizeof(void)

vim +195 net/sched/act_mirred.c

   169  
   170  static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
   171                        struct tcf_result *res)
   172  {
   173          struct tcf_mirred *m = to_mirred(a);
   174          bool m_mac_header_xmit;
   175          struct net_device *dev;
   176          struct sk_buff *skb2;
   177          int retval, err = 0;
   178          bool want_ingress;
   179          int m_eaction;
   180          int mac_len;
   181  
   182          tcf_lastuse_update(&m->tcf_tm);
   183          bstats_cpu_update(this_cpu_ptr(m->common.cpu_bstats), skb);
   184  
   185          m_mac_header_xmit = READ_ONCE(m->tcfm_mac_header_xmit);
   186          m_eaction = READ_ONCE(m->tcfm_eaction);
   187          retval = READ_ONCE(m->tcf_action);
   188          dev = rcu_dereference_bh(m->tcfm_dev);
   189          want_ingress = tcf_mirred_act_wants_ingress(m_eaction);
   190          if (skb_at_tc_ingress(skb) && 
tcf_mirred_is_act_redirect(m_eaction)) {
   191                  skb->tc_redirected = 1;
   192                  skb->tc_from_ingress = 1;
   193  
   194                  /* the core redirect code will check dev and its status 
*/
 > 195                  TCF_RESULT_SET_REDIRECT(res, dev, want_ingress);
   196                  res->qstats = this_cpu_ptr(m->common.cpu_qstats);
   197                  return TC_ACT_REDIRECT;
   198          }
   199  
   200          if (unlikely(!dev)) {
   201                  pr_notice_once("tc mirred: target device is gone\n");
   202                  goto out;
   203          }
   204  
   205          if (unlikely(!(dev->flags & IFF_UP))) {
   206                  net_notice_ratelimited("tc mirred to Houston: device %s 
is down\n",
   207                                         dev->name);
   208                  goto out;
   209          }
   210  
   211          skb2 = skb_clone(skb, GFP_ATOMIC);
   212          if (!skb2)
   213                  goto out;
   214  
   215          /* If action's target direction differs than filter's direction,
   216           * and devices expect a mac header on xmit, then mac push/pull 
is
   217           * needed.
   218           */
   219          if (skb_at_tc_ingress(skb) != want_ingress && 
m_mac_header_xmit) {
   220                  if (!skb_at_tc_ingress(skb)) {
   221                          /* caught at egress, act ingress: pull mac */
   222                          mac_len = skb_network_header(skb) - 
skb_mac_header(skb);
   223                          skb_pull_rcsum(skb2, mac_len);
   224                  } else {
   225                          /* caught at ingress, act egress: push mac */
   226                          skb_push_rcsum(skb2, skb->mac_len);
   227                  }
   228          }
   229  
   230          /* mirror is always swallowed */
   231          if (tcf_mirred_is_act_redirect(m_eaction)) {
   232                  skb2->tc_redirected = 1;
   233                  skb2->tc_from_ingress = skb2->tc_at_ingress;
   234          }
   235  
   236          skb2->skb_iif = skb->dev->ifindex;
   237          skb2->dev = dev;
   238          if (!tcf_mirred_act_wants_ingress(m_eaction))
   239                  err = dev_queue_xmit(skb2);
   240          else
   241                  err = netif_receive_skb(skb2);
   242  
   243          if (err) {
   244  out:
   245                  
qstats_overlimit_inc(this_cpu_ptr(m->common.cpu_qstats));
   246                  if (tcf_mirred_is_act_redirect(m_eaction))
   247                          retval = TC_ACT_SHOT;
   248          }
   249  
   250          return retval;
   251  }
   252  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Reply via email to