Subject: Re: [PATCH net-next] route: allow to route in a peer netns via lwt framework

From: Nicolas Dichtel <[email-masked]>
Date: Fri, 24 Jul 2015 14:24:04 +0200

Le 23/07/2015 17:50, roopa a écrit :
> On 7/23/15, 8:25 AM, Nicolas Dichtel wrote:
>> Le 23/07/2015 17:01, roopa a écrit :
>>> On 7/23/15, 7:22 AM, Nicolas Dichtel wrote:
>> [snip]
>>>> +static inline u32 *lwt_netns_info(struct lwtunnel_state *lwtstate)
>>>> +{
>>>> +    return (u32 *)lwtstate->data;
>>>> +}
>>>> +
>>>> +static inline int skb_lwt_netns_info(struct sk_buff *skb)
>>>> +{
>>>> +    if (skb->protocol == htons(ETH_P_IP)) {
>>>> +        struct rtable *rt = (struct rtable *)skb_dst(skb);
>>>> +
>>>> +        if (rt && rt->rt_lwtstate)
>>>> +            return *lwt_netns_info(rt->rt_lwtstate);
>>>> +    } else if (skb->protocol == htons(ETH_P_IPV6)) {
>>>> +        struct rt6_info *rt6 = (struct rt6_info *)skb_dst(skb);
>>>> +
>>>> +        if (rt6 && rt6->rt6i_lwtstate)
>>>> +            return *lwt_netns_info(rt6->rt6i_lwtstate);
>>>> +    }
>>>> +
>>>> +    return NETNSA_NSID_NOT_ASSIGNED;
>>>> +}
>>>>   #endif /* __NET_LWTUNNEL_H */
>>> since these apis' don't have to be netns specific,
>>> Can they just be named lwtunnel_get_state_data and skb_lwtunnel_state ?
>> They are specific to netns because lwtstate->data is interpreted as an u32 *.
>> But I agree that a test is missing against lwtstate->type to ensure that data
>> will be a nsid.
>>
> o ok..., the api's in lwtunnel.h today are not specific to an encap type.
> they are generic, so skb_lwtunnel_state() which returns struct lwtunnel_state
> could go here.
> the encap specific ones can go in the respective callers. Recently thomas added
> a similar
> skb_tunnel_info() for ip tunnels. I did  like to have a generic version of your
> skb_lwt_netns_info in lwtunnel.h. I could use it in my mpls output func too.
Sure, but my goal was to not create a new .h file just for these two helpers.
It's related to lwtunnel, thus I was thinking they can go here.

Regards,
Nicolas