[Devel] [PATCH RH9 3/3] vzeth: bits and pieces of our interface
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Oct 27 17:47:29 MSK 2021
On 27.10.2021 16:43, Cyrill Gorcunov wrote:
> On Wed, Oct 27, 2021 at 04:05:21PM +0300, Pavel Tikhomirov wrote:
>>
>> +#ifdef CONFIG_VE
>> +static int vzethdev_filter(struct sk_buff *skb, struct net_device *dev, struct net_device *rcv)
>> +{
>> + /* Filtering */
>> + if (ve_is_super(dev_net(dev)->owner_ve) &&
>> + dev->ve_features & NETIF_F_FIXED_ADDR) {
>> + /* from VE0 to VEX */
>> + if (ve_is_super(dev_net(rcv)->owner_ve))
>> + return 1;
>> + if (is_multicast_ether_addr(
>> + ((struct ethhdr *)skb->data)->h_dest))
>> + return 1;
>> + if (!ether_addr_equal(((struct ethhdr *)skb->data)->h_dest,
>> + rcv->dev_addr))
>> + return 0;
>> + } else if (!ve_is_super(dev_net(dev)->owner_ve) &&
>> + dev->ve_features & NETIF_F_FIXED_ADDR) {
>> + /* from VEX to VE0 */
>> + if (!ether_addr_equal(((struct ethhdr *)skb->data)->h_source,
>> + dev->dev_addr))
>> + return 0;
>> + }
>> +
>> + return 1;
>> +}
>> +#endif
>
> Since we're reworking this function anyway how about make it more readable, say
>
> static int vzethdev_filter(struct sk_buff *skb, struct net_device *dev, struct net_device *rcv)
> {
> struct ethhdr *e;
>
> if (!(dev->ve_features & NETIF_F_FIXED_ADDR))
> return 1;
>
> e = (struct ethhdr *)skb->data;
> if (ve_is_super(dev_net(dev)->owner_ve)) {
> /* from VE0 to VEX */
> if (ve_is_super(dev_net(rcv)->owner_ve))
> return 1;
> if (is_multicast_ether_addr(e->h_dest))
> return 1;
> if (!ether_addr_equal(e->h_dest, rcv->dev_addr))
> return 0;
> } else {
> /* from VEX to VE0 */
> if (!ether_addr_equal(e->h_source, dev->dev_addr))
> return 0;
> }
>
> return 1;
> }
>
> if only I didn't miss somthing obvious. Up to you. The patch looks great for me
> in any way.
Nice idea, sent in v2.
>
> Acked-by: Cyrill Gorcunov <gorcunov at gmail.com>
>
--
Best regards, Tikhomirov Pavel
Software Developer, Virtuozzo.
More information about the Devel
mailing list