nfp: bpf: improve wrong FW response warnings
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 29 Mar 2018 00:48:38 +0000 (17:48 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 29 Mar 2018 02:36:14 +0000 (19:36 -0700)
When FW responds with a message of wrong size or type make sure
the type is checked first and included in the wrong size message.
This makes it easier to figure out which FW command failed.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c

index 80d3aa0fc9d3ed817b10a0cdba97d95d48d5a326..7e298148ca26b4899b6f52b4405f4400838ad124 100644 (file)
@@ -218,17 +218,17 @@ nfp_bpf_cmsg_communicate(struct nfp_app_bpf *bpf, struct sk_buff *skb,
                return skb;
 
        hdr = (struct cmsg_hdr *)skb->data;
-       /* 0 reply_size means caller will do the validation */
-       if (reply_size && skb->len != reply_size) {
-               cmsg_warn(bpf, "cmsg drop - wrong size %d != %d!\n",
-                         skb->len, reply_size);
-               goto err_free;
-       }
        if (hdr->type != __CMSG_REPLY(type)) {
                cmsg_warn(bpf, "cmsg drop - wrong type 0x%02x != 0x%02lx!\n",
                          hdr->type, __CMSG_REPLY(type));
                goto err_free;
        }
+       /* 0 reply_size means caller will do the validation */
+       if (reply_size && skb->len != reply_size) {
+               cmsg_warn(bpf, "cmsg drop - type 0x%02x wrong size %d != %d!\n",
+                         type, skb->len, reply_size);
+               goto err_free;
+       }
 
        return skb;
 err_free: