mroute.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef __LINUX_MROUTE_H
  2. #define __LINUX_MROUTE_H
  3. #include <linux/in.h>
  4. #include <linux/pim.h>
  5. #include <net/sock.h>
  6. #include <uapi/linux/mroute.h>
  7. #ifdef CONFIG_IP_MROUTE
  8. static inline int ip_mroute_opt(int opt)
  9. {
  10. return opt >= MRT_BASE && opt <= MRT_MAX;
  11. }
  12. int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
  13. int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  14. int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
  15. int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
  16. int ip_mr_init(void);
  17. #else
  18. static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
  19. char __user *optval, unsigned int optlen)
  20. {
  21. return -ENOPROTOOPT;
  22. }
  23. static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
  24. char __user *optval, int __user *optlen)
  25. {
  26. return -ENOPROTOOPT;
  27. }
  28. static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
  29. {
  30. return -ENOIOCTLCMD;
  31. }
  32. static inline int ip_mr_init(void)
  33. {
  34. return 0;
  35. }
  36. static inline int ip_mroute_opt(int opt)
  37. {
  38. return 0;
  39. }
  40. #endif
  41. struct vif_device {
  42. struct net_device *dev; /* Device we are using */
  43. unsigned long bytes_in,bytes_out;
  44. unsigned long pkt_in,pkt_out; /* Statistics */
  45. unsigned long rate_limit; /* Traffic shaping (NI) */
  46. unsigned char threshold; /* TTL threshold */
  47. unsigned short flags; /* Control flags */
  48. __be32 local,remote; /* Addresses(remote for tunnels)*/
  49. int link; /* Physical interface index */
  50. };
  51. #define VIFF_STATIC 0x8000
  52. #define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
  53. #define MFC_LINES 64
  54. struct mr_table {
  55. struct list_head list;
  56. possible_net_t net;
  57. u32 id;
  58. struct sock __rcu *mroute_sk;
  59. struct timer_list ipmr_expire_timer;
  60. struct list_head mfc_unres_queue;
  61. struct list_head mfc_cache_array[MFC_LINES];
  62. struct vif_device vif_table[MAXVIFS];
  63. int maxvif;
  64. atomic_t cache_resolve_queue_len;
  65. bool mroute_do_assert;
  66. bool mroute_do_pim;
  67. int mroute_reg_vif_num;
  68. };
  69. /* mfc_flags:
  70. * MFC_STATIC - the entry was added statically (not by a routing daemon)
  71. */
  72. enum {
  73. MFC_STATIC = BIT(0),
  74. };
  75. struct mfc_cache {
  76. struct list_head list;
  77. __be32 mfc_mcastgrp; /* Group the entry belongs to */
  78. __be32 mfc_origin; /* Source of packet */
  79. vifi_t mfc_parent; /* Source interface */
  80. int mfc_flags; /* Flags on line */
  81. union {
  82. struct {
  83. unsigned long expires;
  84. struct sk_buff_head unresolved; /* Unresolved buffers */
  85. } unres;
  86. struct {
  87. unsigned long last_assert;
  88. int minvif;
  89. int maxvif;
  90. unsigned long bytes;
  91. unsigned long pkt;
  92. unsigned long wrong_if;
  93. unsigned long lastuse;
  94. unsigned char ttls[MAXVIFS]; /* TTL thresholds */
  95. } res;
  96. } mfc_un;
  97. struct rcu_head rcu;
  98. };
  99. #ifdef __BIG_ENDIAN
  100. #define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
  101. #else
  102. #define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
  103. #endif
  104. struct rtmsg;
  105. int ipmr_get_route(struct net *net, struct sk_buff *skb,
  106. __be32 saddr, __be32 daddr,
  107. struct rtmsg *rtm, int nowait, u32 portid);
  108. #endif