Skip to content

Commit

Permalink
macvtap: Increase limit of macvtap queues
Browse files Browse the repository at this point in the history
Macvtap should be compatible with tuntap for
maximum number of queues.

commit 'baf71c5c1f80d82e92924050a60b5baaf97e3094 (tuntap:
Increase the number of queues in tun.)' removes
the limitations and increases number of queues in tuntap.
Now, Its safe to increase number of queues in Macvtap as well.

This patch also modifies 'macvtap_del_queues' function
to avoid extra memory allocation in stack.

Changes from v1->v2 :
Michael S. Tsirkin, Jason Wang  :
                  Better way to use linked list to
avoid use of extra memory in stack.
Sergei Shtylyov : Specify dependent commit's summary.

Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pankaj Gupta authored and David S. Miller committed Jun 23, 2015
1 parent 0fb1170 commit dfe816c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,27 +263,21 @@ static struct macvtap_queue *macvtap_get_queue(struct net_device *dev,
static void macvtap_del_queues(struct net_device *dev)
{
struct macvlan_dev *vlan = netdev_priv(dev);
struct macvtap_queue *q, *tmp, *qlist[MAX_MACVTAP_QUEUES];
int i, j = 0;
struct macvtap_queue *q, *tmp;

ASSERT_RTNL();
list_for_each_entry_safe(q, tmp, &vlan->queue_list, next) {
list_del_init(&q->next);
qlist[j++] = q;
RCU_INIT_POINTER(q->vlan, NULL);
if (q->enabled)
vlan->numvtaps--;
vlan->numqueues--;
sock_put(&q->sk);
}
for (i = 0; i < vlan->numvtaps; i++)
RCU_INIT_POINTER(vlan->taps[i], NULL);
BUG_ON(vlan->numvtaps);
BUG_ON(vlan->numqueues);
/* guarantee that any future macvtap_set_queue will fail */
vlan->numvtaps = MAX_MACVTAP_QUEUES;

for (--j; j >= 0; j--)
sock_put(&qlist[j]->sk);
}

static rx_handler_result_t macvtap_handle_frame(struct sk_buff **pskb)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/if_macvlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct macvtap_queue;
* Maximum times a macvtap device can be opened. This can be used to
* configure the number of receive queue, e.g. for multiqueue virtio.
*/
#define MAX_MACVTAP_QUEUES 16
#define MAX_MACVTAP_QUEUES 256

#define MACVLAN_MC_FILTER_BITS 8
#define MACVLAN_MC_FILTER_SZ (1 << MACVLAN_MC_FILTER_BITS)
Expand Down

0 comments on commit dfe816c

Please sign in to comment.