if_bridge.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Linux ethernet bridge
  4. *
  5. * Authors:
  6. * Lennert Buytenhek <buytenh@gnu.org>
  7. */
  8. #ifndef _LINUX_IF_BRIDGE_H
  9. #define _LINUX_IF_BRIDGE_H
  10. #include <linux/netdevice.h>
  11. #include <uapi/linux/if_bridge.h>
  12. #include <linux/bitops.h>
  13. struct br_ip {
  14. union {
  15. __be32 ip4;
  16. #if IS_ENABLED(CONFIG_IPV6)
  17. struct in6_addr ip6;
  18. #endif
  19. } src;
  20. union {
  21. __be32 ip4;
  22. #if IS_ENABLED(CONFIG_IPV6)
  23. struct in6_addr ip6;
  24. #endif
  25. } dst;
  26. __be16 proto;
  27. __u16 vid;
  28. };
  29. struct br_ip_list {
  30. struct list_head list;
  31. struct br_ip addr;
  32. };
  33. #define BR_HAIRPIN_MODE BIT(0)
  34. #define BR_BPDU_GUARD BIT(1)
  35. #define BR_ROOT_BLOCK BIT(2)
  36. #define BR_MULTICAST_FAST_LEAVE BIT(3)
  37. #define BR_ADMIN_COST BIT(4)
  38. #define BR_LEARNING BIT(5)
  39. #define BR_FLOOD BIT(6)
  40. #define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
  41. #define BR_PROMISC BIT(7)
  42. #define BR_PROXYARP BIT(8)
  43. #define BR_LEARNING_SYNC BIT(9)
  44. #define BR_PROXYARP_WIFI BIT(10)
  45. #define BR_MCAST_FLOOD BIT(11)
  46. #define BR_MULTICAST_TO_UNICAST BIT(12)
  47. #define BR_VLAN_TUNNEL BIT(13)
  48. #define BR_BCAST_FLOOD BIT(14)
  49. #define BR_NEIGH_SUPPRESS BIT(15)
  50. #define BR_ISOLATED BIT(16)
  51. #define BR_MRP_AWARE BIT(17)
  52. #define BR_MRP_LOST_CONT BIT(18)
  53. #define BR_MRP_LOST_IN_CONT BIT(19)
  54. #define BR_DEFAULT_AGEING_TIME (300 * HZ)
  55. extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
  56. #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)
  57. int br_multicast_list_adjacent(struct net_device *dev,
  58. struct list_head *br_ip_list);
  59. bool br_multicast_has_querier_anywhere(struct net_device *dev, int proto);
  60. bool br_multicast_has_querier_adjacent(struct net_device *dev, int proto);
  61. bool br_multicast_enabled(const struct net_device *dev);
  62. bool br_multicast_router(const struct net_device *dev);
  63. #else
  64. static inline int br_multicast_list_adjacent(struct net_device *dev,
  65. struct list_head *br_ip_list)
  66. {
  67. return 0;
  68. }
  69. static inline bool br_multicast_has_querier_anywhere(struct net_device *dev,
  70. int proto)
  71. {
  72. return false;
  73. }
  74. static inline bool br_multicast_has_querier_adjacent(struct net_device *dev,
  75. int proto)
  76. {
  77. return false;
  78. }
  79. static inline bool br_multicast_enabled(const struct net_device *dev)
  80. {
  81. return false;
  82. }
  83. static inline bool br_multicast_router(const struct net_device *dev)
  84. {
  85. return false;
  86. }
  87. #endif
  88. #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_VLAN_FILTERING)
  89. bool br_vlan_enabled(const struct net_device *dev);
  90. int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid);
  91. int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid);
  92. int br_vlan_get_proto(const struct net_device *dev, u16 *p_proto);
  93. int br_vlan_get_info(const struct net_device *dev, u16 vid,
  94. struct bridge_vlan_info *p_vinfo);
  95. #else
  96. static inline bool br_vlan_enabled(const struct net_device *dev)
  97. {
  98. return false;
  99. }
  100. static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
  101. {
  102. return -EINVAL;
  103. }
  104. static inline int br_vlan_get_proto(const struct net_device *dev, u16 *p_proto)
  105. {
  106. return -EINVAL;
  107. }
  108. static inline int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid)
  109. {
  110. return -EINVAL;
  111. }
  112. static inline int br_vlan_get_info(const struct net_device *dev, u16 vid,
  113. struct bridge_vlan_info *p_vinfo)
  114. {
  115. return -EINVAL;
  116. }
  117. #endif
  118. #if IS_ENABLED(CONFIG_BRIDGE)
  119. struct net_device *br_fdb_find_port(const struct net_device *br_dev,
  120. const unsigned char *addr,
  121. __u16 vid);
  122. void br_fdb_clear_offload(const struct net_device *dev, u16 vid);
  123. bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag);
  124. #else
  125. static inline struct net_device *
  126. br_fdb_find_port(const struct net_device *br_dev,
  127. const unsigned char *addr,
  128. __u16 vid)
  129. {
  130. return NULL;
  131. }
  132. static inline void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
  133. {
  134. }
  135. static inline bool
  136. br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
  137. {
  138. return false;
  139. }
  140. #endif
  141. #endif