ipcommon.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* net/atm/ipcommon.c - Common items for all ways of doing IP over ATM */
  2. /* Written 1996-2000 by Werner Almesberger, EPFL LRC/ICA */
  3. #include <linux/module.h>
  4. #include <linux/string.h>
  5. #include <linux/skbuff.h>
  6. #include <linux/netdevice.h>
  7. #include <linux/in.h>
  8. #include <linux/atmdev.h>
  9. #include <linux/atmclip.h>
  10. #include "common.h"
  11. #include "ipcommon.h"
  12. #if 0
  13. #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
  14. #else
  15. #define DPRINTK(format,args...)
  16. #endif
  17. /*
  18. * skb_migrate appends the list at "from" to "to", emptying "from" in the
  19. * process. skb_migrate is atomic with respect to all other skb operations on
  20. * "from" and "to". Note that it locks both lists at the same time, so beware
  21. * of potential deadlocks.
  22. *
  23. * This function should live in skbuff.c or skbuff.h.
  24. */
  25. void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to)
  26. {
  27. unsigned long flags;
  28. struct sk_buff *skb_from = (struct sk_buff *) from;
  29. struct sk_buff *skb_to = (struct sk_buff *) to;
  30. struct sk_buff *prev;
  31. spin_lock_irqsave(&from->lock,flags);
  32. spin_lock(&to->lock);
  33. prev = from->prev;
  34. from->next->prev = to->prev;
  35. prev->next = skb_to;
  36. to->prev->next = from->next;
  37. to->prev = from->prev;
  38. to->qlen += from->qlen;
  39. spin_unlock(&to->lock);
  40. from->prev = skb_from;
  41. from->next = skb_from;
  42. from->qlen = 0;
  43. spin_unlock_irqrestore(&from->lock,flags);
  44. }
  45. EXPORT_SYMBOL(skb_migrate);