__u8 *optval = ctx->optval;
        struct sockopt_sk *storage;
 
+       /* Make sure bpf_get_netns_cookie is callable.
+        */
+       if (bpf_get_netns_cookie(NULL) == 0)
+               return 0;
+
+       if (bpf_get_netns_cookie(ctx) == 0)
+               return 0;
+
        if (ctx->level == SOL_IP && ctx->optname == IP_TOS) {
                /* Not interested in SOL_IP:IP_TOS;
                 * let next BPF program in the cgroup chain or kernel
        __u8 *optval = ctx->optval;
        struct sockopt_sk *storage;
 
+       /* Make sure bpf_get_netns_cookie is callable.
+        */
+       if (bpf_get_netns_cookie(NULL) == 0)
+               return 0;
+
+       if (bpf_get_netns_cookie(ctx) == 0)
+               return 0;
+
        if (ctx->level == SOL_IP && ctx->optname == IP_TOS) {
                /* Not interested in SOL_IP:IP_TOS;
                 * let next BPF program in the cgroup chain or kernel