if_bridge.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Linux ethernet bridge
  3. *
  4. * Authors:
  5. * Lennert Buytenhek <buytenh@gnu.org>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #ifndef _LINUX_IF_BRIDGE_H
  13. #define _LINUX_IF_BRIDGE_H
  14. #include <linux/netdevice.h>
  15. #include <uapi/linux/if_bridge.h>
  16. #include <linux/bitops.h>
  17. struct br_ip {
  18. union {
  19. __be32 ip4;
  20. #if IS_ENABLED(CONFIG_IPV6)
  21. struct in6_addr ip6;
  22. #endif
  23. } u;
  24. __be16 proto;
  25. __u16 vid;
  26. };
  27. struct br_ip_list {
  28. struct list_head list;
  29. struct br_ip addr;
  30. };
  31. #define BR_HAIRPIN_MODE BIT(0)
  32. #define BR_BPDU_GUARD BIT(1)
  33. #define BR_ROOT_BLOCK BIT(2)
  34. #define BR_MULTICAST_FAST_LEAVE BIT(3)
  35. #define BR_ADMIN_COST BIT(4)
  36. #define BR_LEARNING BIT(5)
  37. #define BR_FLOOD BIT(6)
  38. #define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
  39. #define BR_PROMISC BIT(7)
  40. #define BR_PROXYARP BIT(8)
  41. #define BR_LEARNING_SYNC BIT(9)
  42. #define BR_PROXYARP_WIFI BIT(10)
  43. #define BR_MCAST_FLOOD BIT(11)
  44. #define BR_MULTICAST_TO_UNICAST BIT(12)
  45. #define BR_VLAN_TUNNEL BIT(13)
  46. #define BR_BCAST_FLOOD BIT(14)
  47. #define BR_NEIGH_SUPPRESS BIT(15)
  48. #define BR_ISOLATED BIT(16)
  49. #define BR_DEFAULT_AGEING_TIME (300 * HZ)
  50. extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
  51. typedef int br_should_route_hook_t(struct sk_buff *skb);
  52. extern br_should_route_hook_t __rcu *br_should_route_hook;
  53. #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)
  54. int br_multicast_list_adjacent(struct net_device *dev,
  55. struct list_head *br_ip_list);
  56. bool br_multicast_has_querier_anywhere(struct net_device *dev, int proto);
  57. bool br_multicast_has_querier_adjacent(struct net_device *dev, int proto);
  58. bool br_multicast_enabled(const struct net_device *dev);
  59. bool br_multicast_router(const struct net_device *dev);
  60. #else
  61. static inline int br_multicast_list_adjacent(struct net_device *dev,
  62. struct list_head *br_ip_list)
  63. {
  64. return 0;
  65. }
  66. static inline bool br_multicast_has_querier_anywhere(struct net_device *dev,
  67. int proto)
  68. {
  69. return false;
  70. }
  71. static inline bool br_multicast_has_querier_adjacent(struct net_device *dev,
  72. int proto)
  73. {
  74. return false;
  75. }
  76. static inline bool br_multicast_enabled(const struct net_device *dev)
  77. {
  78. return false;
  79. }
  80. static inline bool br_multicast_router(const struct net_device *dev)
  81. {
  82. return false;
  83. }
  84. #endif
  85. #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_VLAN_FILTERING)
  86. bool br_vlan_enabled(const struct net_device *dev);
  87. int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid);
  88. int br_vlan_get_info(const struct net_device *dev, u16 vid,
  89. struct bridge_vlan_info *p_vinfo);
  90. #else
  91. static inline bool br_vlan_enabled(const struct net_device *dev)
  92. {
  93. return false;
  94. }
  95. static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
  96. {
  97. return -EINVAL;
  98. }
  99. static inline int br_vlan_get_info(const struct net_device *dev, u16 vid,
  100. struct bridge_vlan_info *p_vinfo)
  101. {
  102. return -EINVAL;
  103. }
  104. #endif
  105. #if IS_ENABLED(CONFIG_BRIDGE)
  106. struct net_device *br_fdb_find_port(const struct net_device *br_dev,
  107. const unsigned char *addr,
  108. __u16 vid);
  109. #else
  110. static inline struct net_device *
  111. br_fdb_find_port(const struct net_device *br_dev,
  112. const unsigned char *addr,
  113. __u16 vid)
  114. {
  115. return NULL;
  116. }
  117. #endif
  118. #endif