Re: [PATCH net-next v2 1/2] mpls: allow TTL propagation to IP packets to be configured

2017-03-10 Thread Robert Shearman

On 10/03/17 02:00, David Ahern wrote:

On 3/7/17 5:46 PM, Robert Shearman wrote:

@@ -244,24 +245,33 @@ static bool mpls_egress(struct mpls_route *rt, struct 
sk_buff *skb,
payload_type = ip_hdr(skb)->version;

switch (payload_type) {
-   case MPT_IPV4: {
-   struct iphdr *hdr4 = ip_hdr(skb);
+   case MPT_IPV4:
+   if (rt->rt_ttl_propagate == MPLS_TTL_PROP_ENABLED ||
+   (rt->rt_ttl_propagate == MPLS_TTL_PROP_DEFAULT &&
+net->mpls.ip_ttl_propagate)) {
+   struct iphdr *hdr4 = ip_hdr(skb);
+
+   csum_replace2(>check,
+ htons(hdr4->ttl << 8),
+ htons(dec.ttl << 8));
+   hdr4->ttl = dec.ttl;
+   }
skb->protocol = htons(ETH_P_IP);
-   csum_replace2(>check,
- htons(hdr4->ttl << 8),
- htons(dec.ttl << 8));
-   hdr4->ttl = dec.ttl;
success = true;
break;
-   }
-   case MPT_IPV6: {
-   struct ipv6hdr *hdr6 = ipv6_hdr(skb);
+   case MPT_IPV6:
+   if (rt->rt_ttl_propagate == MPLS_TTL_PROP_ENABLED ||
+   (rt->rt_ttl_propagate == MPLS_TTL_PROP_DEFAULT &&
+net->mpls.ip_ttl_propagate)) {
+   struct ipv6hdr *hdr6 = ipv6_hdr(skb);
+
+   hdr6->hop_limit = dec.ttl;
+   }
skb->protocol = htons(ETH_P_IPV6);
-   hdr6->hop_limit = dec.ttl;
success = true;
break;
-   }


What decrements the TTL if it is not propagated from MPLS to IP?



Good point. Will address in v3.

Thanks,
Rob


Re: [PATCH net-next v2 1/2] mpls: allow TTL propagation to IP packets to be configured

2017-03-10 Thread Robert Shearman

On 10/03/17 02:40, David Ahern wrote:

On 3/7/17 5:46 PM, Robert Shearman wrote:

diff --git a/include/net/netns/mpls.h b/include/net/netns/mpls.h
index d29203651c01..58e0e46c4a5c 100644
--- a/include/net/netns/mpls.h
+++ b/include/net/netns/mpls.h
@@ -10,7 +10,9 @@ struct ctl_table_header;

 struct netns_mpls {
size_t platform_labels;
+   int ip_ttl_propagate;
struct mpls_route __rcu * __rcu *platform_label;
+
struct ctl_table_header *ctl;
 };



I'd prefer the platform_labels stay with platform_label. ie., put the
new ip_ttl_propagate above platform_labels.



Ok, will do in v3.

Thanks,
Rob


Re: [PATCH net-next v2 1/2] mpls: allow TTL propagation to IP packets to be configured

2017-03-09 Thread David Ahern
On 3/7/17 5:46 PM, Robert Shearman wrote:
> diff --git a/include/net/netns/mpls.h b/include/net/netns/mpls.h
> index d29203651c01..58e0e46c4a5c 100644
> --- a/include/net/netns/mpls.h
> +++ b/include/net/netns/mpls.h
> @@ -10,7 +10,9 @@ struct ctl_table_header;
>  
>  struct netns_mpls {
>   size_t platform_labels;
> + int ip_ttl_propagate;
>   struct mpls_route __rcu * __rcu *platform_label;
> +
>   struct ctl_table_header *ctl;
>  };
>  

I'd prefer the platform_labels stay with platform_label. ie., put the
new ip_ttl_propagate above platform_labels.


Re: [PATCH net-next v2 1/2] mpls: allow TTL propagation to IP packets to be configured

2017-03-09 Thread David Ahern
On 3/7/17 5:46 PM, Robert Shearman wrote:
> @@ -244,24 +245,33 @@ static bool mpls_egress(struct mpls_route *rt, struct 
> sk_buff *skb,
>   payload_type = ip_hdr(skb)->version;
>  
>   switch (payload_type) {
> - case MPT_IPV4: {
> - struct iphdr *hdr4 = ip_hdr(skb);
> + case MPT_IPV4:
> + if (rt->rt_ttl_propagate == MPLS_TTL_PROP_ENABLED ||
> + (rt->rt_ttl_propagate == MPLS_TTL_PROP_DEFAULT &&
> +  net->mpls.ip_ttl_propagate)) {
> + struct iphdr *hdr4 = ip_hdr(skb);
> +
> + csum_replace2(>check,
> +   htons(hdr4->ttl << 8),
> +   htons(dec.ttl << 8));
> + hdr4->ttl = dec.ttl;
> + }
>   skb->protocol = htons(ETH_P_IP);
> - csum_replace2(>check,
> -   htons(hdr4->ttl << 8),
> -   htons(dec.ttl << 8));
> - hdr4->ttl = dec.ttl;
>   success = true;
>   break;
> - }
> - case MPT_IPV6: {
> - struct ipv6hdr *hdr6 = ipv6_hdr(skb);
> + case MPT_IPV6:
> + if (rt->rt_ttl_propagate == MPLS_TTL_PROP_ENABLED ||
> + (rt->rt_ttl_propagate == MPLS_TTL_PROP_DEFAULT &&
> +  net->mpls.ip_ttl_propagate)) {
> + struct ipv6hdr *hdr6 = ipv6_hdr(skb);
> +
> + hdr6->hop_limit = dec.ttl;
> + }
>   skb->protocol = htons(ETH_P_IPV6);
> - hdr6->hop_limit = dec.ttl;
>   success = true;
>   break;
> - }

What decrements the TTL if it is not propagated from MPLS to IP?