xen-netback: add support for multicast control
PATCH 1/1 xen-netback: add support for multicast control
Xen's PV network protocol includes messages to add/remove ethernet multicast addresses to/from a filter list in the backend. This allows the frontend to request the backend only forward multicast packets which are off interest thus preventing unnecessary noise on the shared ring.
The canonical netif header in git://xenbits.xen.org/xen.git specifies the message format (two more XEN_NETIF_EXTRA_TYPEs) so the minimal necessary changes have been pulled into include/xen/interface/io/netif.h.
To prevent the frontend from extending the multicast filter list arbitrarily a limit (XEN_NETBK_MCAST_MAX) has been set to 64 entries. This limit is not specified by the protocol and so may change in future. If the limit is reached then the next XEN_NETIF_EXTRA_TYPE_MCAST_ADD sent by the frontend will be failed with NETIF_RSP_ERROR.
--- drivers/net/xen-netback/common.h | 15 ++++++ drivers/net/xen-netback/interface.c | 10 ++++ drivers/net/xen-netback/netback.c | 99 +++++++++++++++++++++++++++++++++++ drivers/net/xen-netback/xenbus.c | 13 +++++ include/xen/interface/io/netif.h | 8 ++- 5 files changed, 144 insertions(+), 1 deletion(-)
drivers/net/xen-netback/common.h +15 -0
@@ -210,12 +210,22 @@ enum state_bit_shift { VIF_STATUS_CONNECTED, }; +struct xenvif_mcast_addr { +struct list_head entry; +struct rcu_head rcu; +u8 addr[6 ]; +}; + +#define XEN_NETBK_MCAST_MAX 64 +struct xenvif {/* Unique identifier for this interface. */ domid_t domid;unsigned int handle;u8 fe_dev_addr[6 ]; +struct list_head fe_mcast_addr; +unsigned int fe_mcast_count;/* Frontend feature information. */ int gso_mask;
@@ -224,6 +234,7 @@ struct xenvif { u8 can_sg:1; u8 ip_csum:1; u8 ipv6_csum:1; + u8 multicast_control:1;/* Is this interface disabled? True when backend discovers * frontend is rogue.
@@ -341,4 +352,8 @@ void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue, struct sk_buff *skb);void xenvif_skb_zerocopy_complete (struct xenvif_queue *queue); +/* Multicast control */ +bool xenvif_mcast_match (struct xenvif *vif,const u8 *addr); +void xenvif_mcast_flush (struct xenvif *vif); +#endif /* __XEN_NETBACK__COMMON_H__ */
drivers/net/xen-netback/interface.c +10 -0
@@ -171,6 +171,13 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) !xenvif_schedulable(vif)) goto drop; +if (vif->multicast_control && skb->pkt_type ==PACKET_MULTICAST ) { +struct ethhdr *eth = (struct ethhdr *)skb->data; + +if (!xenvif_mcast_match (vif, eth->h_dest)) + goto drop; + } + cb =XENVIF_RX_CB (skb); cb->expires = jiffies + vif->drain_timeout;
@@ -427,6 +434,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, vif->num_queues =0 ;spin_lock_init (&vif->lock); +INIT_LIST_HEAD (&vif->fe_mcast_addr); dev->netdev_ops = &xenvif_netdev_ops; dev->hw_features = NETIF_F_SG |
@@ -661,6 +669,8 @@ void xenvif_disconnect(struct xenvif *vif)xenvif_unmap_frontend_rings (queue); } + +xenvif_mcast_flush (vif); }/* Reverse the relevant parts of xenvif_init_queue().
drivers/net/xen-netback/netback.c +99 -0
111 lines not on this page · raw message
drivers/net/xen-netback/xenbus.c +13 -0
@@ -327,6 +327,14 @@ static int netback_probe(struct xenbus_device *dev, goto abort_transaction; } +/* We support multicast-control. */ + err =xenbus_printf (xbt, dev->nodename, +"feature-multicast-control" ,"%d" ,1 ); +if (err) { + message ="writing feature-multicast-control" ; + goto abort_transaction; + } + err =xenbus_transaction_end (xbt,0 ); }while (err == -EAGAIN );
@@ -1016,6 +1024,11 @@ static int read_xenbus_vif_flags(struct backend_info *be) val =0 ; vif->ipv6_csum = !!val; +if (xenbus_scanf (XBT_NIL , dev->otherend,"request-multicast-control" , +"%d" , &val) <0 ) + val =0 ; + vif->multicast_control = !!val; +return 0 ; }
include/xen/interface/io/netif.h +7 -1
@@ -156,7 +156,9 @@ struct xen_netif_tx_request {/* Types of xen_netif_extra_info descriptors. */ #define XEN_NETIF_EXTRA_TYPE_NONE (0)/* Never used - invalid */ #define XEN_NETIF_EXTRA_TYPE_GSO (1)/* u.gso */ -#define XEN_NETIF_EXTRA_TYPE_MAX (2) +#define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2)/* u.mcast */ +#define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3)/* u.mcast */ +#define XEN_NETIF_EXTRA_TYPE_MAX (4)/* xen_netif_extra_info flags. */ #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
@@ -201,6 +203,10 @@ struct xen_netif_extra_info {uint16_t features;/* XEN_NETIF_GSO_FEAT_* */ } gso; +struct { +uint8_t addr[6 ];/* Address to add/remove. */ + } mcast; +uint16_t pad[3 ]; } u; };
Signature · 1 line
1.7.10.4
Quoted 4 lines · Paul Durrant
Xen's PV network protocol includes messages to add/remove ethernet multicast addresses to/from a filter list in the backend. This allows the frontend to request the backend only forward multicast packets which are off interest thus preventing unnecessary noise on the shared
"of interest"
Quoted 2 lines
ring.
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ +void xenvif_mcast_flush(struct xenvif *vif)
Only one cosmetic comment.
My first impression of this function by looking at the name is that it flushes queued multicast packets. Maybe we can rename it to xenvif_mcast_addr_list_free ?
Wei.
Quoted 8 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 02 September 2015 15:01
To: Paul Durrant
Cc: [email protected]; [email protected]; Ian Campbell; Wei Liu
Subject: Re: [PATCH net-next] xen-netback: add support for multicast control
Quoted 7 lines
Quoted 4 lines · Paul Durrant
Xen's PV network protocol includes messages to add/remove ethernet multicast addresses to/from a filter list in the backend. This allows the frontend to request the backend only forward multicast packets which are off interest thus preventing unnecessary noise on the shared
"of interest"
Ah yes :-)
Quoted 4 lines
Quoted 3 lines
ring.
[...]
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +void xenvif_mcast_flush(struct xenvif *vif)Only one cosmetic comment.
My first impression of this function by looking at the name is that it flushes queued multicast packets. Maybe we can rename it to
xenvif_mcast_addr_list_free?
Sure.
Paul
Quoted 1 line
Wei.
Quoted 8 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 02 September 2015 15:01
To: Paul Durrant
Cc: [email protected]; [email protected]; Ian Campbell; Wei Liu
Subject: Re: [PATCH net-next] xen-netback: add support for multicast control
Quoted 7 lines
Quoted 4 lines · Paul Durrant
Xen's PV network protocol includes messages to add/remove ethernet multicast addresses to/from a filter list in the backend. This allows the frontend to request the backend only forward multicast packets which are off interest thus preventing unnecessary noise on the shared
"of interest"
Ah yes :-)
Quoted 4 lines
Quoted 3 lines
ring.
[...]
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +void xenvif_mcast_flush(struct xenvif *vif)Only one cosmetic comment.
My first impression of this function by looking at the name is that it flushes queued multicast packets. Maybe we can rename it to
xenvif_mcast_addr_list_free?
Sure.
Paul
Quoted 1 line
Wei.
Quoted 4 lines · Paul Durrant
Xen's PV network protocol includes messages to add/remove ethernet multicast addresses to/from a filter list in the backend. This allows the frontend to request the backend only forward multicast packets which are off interest thus preventing unnecessary noise on the shared
"of interest"
Quoted 2 lines
ring.
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ +void xenvif_mcast_flush(struct xenvif *vif)
Only one cosmetic comment.
My first impression of this function by looking at the name is that it flushes queued multicast packets. Maybe we can rename it to xenvif_mcast_addr_list_free ?
Wei.