btrfs: fix race between quota disable and quota assign ioctls
[platform/kernel/linux-rpi.git] / net / ipv6 / seg6.c
index 0718529..0c7c6fc 100644 (file)
@@ -104,6 +104,36 @@ struct ipv6_sr_hdr *seg6_get_srh(struct sk_buff *skb, int flags)
        return srh;
 }
 
+/* Determine if an ICMP invoking packet contains a segment routing
+ * header.  If it does, extract the offset to the true destination
+ * address, which is in the first segment address.
+ */
+void seg6_icmp_srh(struct sk_buff *skb, struct inet6_skb_parm *opt)
+{
+       __u16 network_header = skb->network_header;
+       struct ipv6_sr_hdr *srh;
+
+       /* Update network header to point to the invoking packet
+        * inside the ICMP packet, so we can use the seg6_get_srh()
+        * helper.
+        */
+       skb_reset_network_header(skb);
+
+       srh = seg6_get_srh(skb, 0);
+       if (!srh)
+               goto out;
+
+       if (srh->type != IPV6_SRCRT_TYPE_4)
+               goto out;
+
+       opt->flags |= IP6SKB_SEG6;
+       opt->srhoff = (unsigned char *)srh - skb->data;
+
+out:
+       /* Restore the network header back to the ICMP packet */
+       skb->network_header = network_header;
+}
+
 static struct genl_family seg6_genl_family;
 
 static const struct nla_policy seg6_genl_policy[SEG6_ATTR_MAX + 1] = {
@@ -161,6 +191,11 @@ static int seg6_genl_sethmac(struct sk_buff *skb, struct genl_info *info)
                goto out_unlock;
        }
 
+       if (slen > nla_len(info->attrs[SEG6_ATTR_SECRET])) {
+               err = -EINVAL;
+               goto out_unlock;
+       }
+
        if (hinfo) {
                err = seg6_hmac_info_del(net, hmackeyid);
                if (err)