| .. | .. |
|---|
| 13 | 13 | #include "qeth_core.h" |
|---|
| 14 | 14 | #include <linux/hashtable.h> |
|---|
| 15 | 15 | |
|---|
| 16 | | -#define QETH_SNIFF_AVAIL 0x0008 |
|---|
| 17 | | - |
|---|
| 18 | 16 | enum qeth_ip_types { |
|---|
| 19 | 17 | QETH_IP_TYPE_NORMAL, |
|---|
| 20 | 18 | QETH_IP_TYPE_VIPA, |
|---|
| .. | .. |
|---|
| 24 | 22 | struct qeth_ipaddr { |
|---|
| 25 | 23 | struct hlist_node hnode; |
|---|
| 26 | 24 | enum qeth_ip_types type; |
|---|
| 27 | | - unsigned char mac[ETH_ALEN]; |
|---|
| 28 | 25 | u8 is_multicast:1; |
|---|
| 29 | | - u8 in_progress:1; |
|---|
| 30 | 26 | u8 disp_flag:2; |
|---|
| 31 | 27 | u8 ipato:1; /* ucast only */ |
|---|
| 32 | 28 | |
|---|
| .. | .. |
|---|
| 37 | 33 | enum qeth_prot_versions proto; |
|---|
| 38 | 34 | union { |
|---|
| 39 | 35 | struct { |
|---|
| 40 | | - unsigned int addr; |
|---|
| 41 | | - unsigned int mask; |
|---|
| 36 | + __be32 addr; |
|---|
| 37 | + __be32 mask; |
|---|
| 42 | 38 | } a4; |
|---|
| 43 | 39 | struct { |
|---|
| 44 | 40 | struct in6_addr addr; |
|---|
| .. | .. |
|---|
| 55 | 51 | addr->type = type; |
|---|
| 56 | 52 | addr->proto = proto; |
|---|
| 57 | 53 | addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
|---|
| 54 | + addr->ref_counter = 1; |
|---|
| 58 | 55 | } |
|---|
| 59 | 56 | |
|---|
| 60 | 57 | static inline bool qeth_l3_addr_match_ip(struct qeth_ipaddr *a1, |
|---|
| .. | .. |
|---|
| 74 | 71 | * so 'proto' and 'addr' match for sure. |
|---|
| 75 | 72 | * |
|---|
| 76 | 73 | * For ucast: |
|---|
| 77 | | - * - 'mac' is always 0. |
|---|
| 78 | 74 | * - 'mask'/'pfxlen' for RXIP/VIPA is always 0. For NORMAL, matching |
|---|
| 79 | 75 | * values are required to avoid mixups in takeover eligibility. |
|---|
| 80 | 76 | * |
|---|
| 81 | 77 | * For mcast, |
|---|
| 82 | | - * - 'mac' is mapped from the IP, and thus always matches. |
|---|
| 83 | 78 | * - 'mask'/'pfxlen' is always 0. |
|---|
| 84 | 79 | */ |
|---|
| 85 | 80 | if (a1->type != a2->type) |
|---|
| .. | .. |
|---|
| 89 | 84 | return a1->u.a4.mask == a2->u.a4.mask; |
|---|
| 90 | 85 | } |
|---|
| 91 | 86 | |
|---|
| 92 | | -static inline u64 qeth_l3_ipaddr_hash(struct qeth_ipaddr *addr) |
|---|
| 87 | +static inline u32 qeth_l3_ipaddr_hash(struct qeth_ipaddr *addr) |
|---|
| 93 | 88 | { |
|---|
| 94 | | - u64 ret = 0; |
|---|
| 95 | | - u8 *point; |
|---|
| 96 | | - |
|---|
| 97 | | - if (addr->proto == QETH_PROT_IPV6) { |
|---|
| 98 | | - point = (u8 *) &addr->u.a6.addr; |
|---|
| 99 | | - ret = get_unaligned((u64 *)point) ^ |
|---|
| 100 | | - get_unaligned((u64 *) (point + 8)); |
|---|
| 101 | | - } |
|---|
| 102 | | - if (addr->proto == QETH_PROT_IPV4) { |
|---|
| 103 | | - point = (u8 *) &addr->u.a4.addr; |
|---|
| 104 | | - ret = get_unaligned((u32 *) point); |
|---|
| 105 | | - } |
|---|
| 106 | | - return ret; |
|---|
| 89 | + if (addr->proto == QETH_PROT_IPV6) |
|---|
| 90 | + return ipv6_addr_hash(&addr->u.a6.addr); |
|---|
| 91 | + else |
|---|
| 92 | + return ipv4_addr_hash(addr->u.a4.addr); |
|---|
| 107 | 93 | } |
|---|
| 108 | 94 | |
|---|
| 109 | 95 | struct qeth_ipato_entry { |
|---|
| 110 | 96 | struct list_head entry; |
|---|
| 111 | 97 | enum qeth_prot_versions proto; |
|---|
| 112 | 98 | char addr[16]; |
|---|
| 113 | | - int mask_bits; |
|---|
| 99 | + unsigned int mask_bits; |
|---|
| 114 | 100 | }; |
|---|
| 115 | 101 | |
|---|
| 116 | 102 | extern const struct attribute_group *qeth_l3_attr_groups[]; |
|---|
| 117 | 103 | |
|---|
| 118 | | -void qeth_l3_ipaddr_to_string(enum qeth_prot_versions, const __u8 *, char *); |
|---|
| 104 | +int qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const u8 *addr, |
|---|
| 105 | + char *buf); |
|---|
| 119 | 106 | int qeth_l3_create_device_attributes(struct device *); |
|---|
| 120 | 107 | void qeth_l3_remove_device_attributes(struct device *); |
|---|
| 121 | 108 | int qeth_l3_setrouting_v4(struct qeth_card *); |
|---|
| .. | .. |
|---|
| 123 | 110 | int qeth_l3_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *); |
|---|
| 124 | 111 | int qeth_l3_del_ipato_entry(struct qeth_card *card, |
|---|
| 125 | 112 | enum qeth_prot_versions proto, u8 *addr, |
|---|
| 126 | | - int mask_bits); |
|---|
| 113 | + unsigned int mask_bits); |
|---|
| 127 | 114 | void qeth_l3_update_ipato(struct qeth_card *card); |
|---|
| 128 | 115 | int qeth_l3_modify_hsuid(struct qeth_card *card, bool add); |
|---|
| 129 | 116 | int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip, |
|---|