Commit eceb22ae0bdcb49daff9989f91fb3388fa501a69
Committed by
Antonio Quartulli
1 parent
2d2fcc2a3f
batman-adv: create helper function to get AP isolation status
The AP isolation status may be evaluated in different spots. Create an helper function to avoid code duplication. Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Showing 3 changed files with 28 additions and 12 deletions Side-by-side Diff
net/batman-adv/main.c
... | ... | @@ -1171,6 +1171,32 @@ |
1171 | 1171 | return vid; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | +/** | |
1175 | + * batadv_vlan_ap_isola_get - return the AP isolation status for the given vlan | |
1176 | + * @bat_priv: the bat priv with all the soft interface information | |
1177 | + * @vid: the VLAN identifier for which the AP isolation attributed as to be | |
1178 | + * looked up | |
1179 | + * | |
1180 | + * Returns true if AP isolation is on for the VLAN idenfied by vid, false | |
1181 | + * otherwise | |
1182 | + */ | |
1183 | +bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid) | |
1184 | +{ | |
1185 | + bool ap_isolation_enabled = false; | |
1186 | + struct batadv_softif_vlan *vlan; | |
1187 | + | |
1188 | + /* if the AP isolation is requested on a VLAN, then check for its | |
1189 | + * setting in the proper VLAN private data structure | |
1190 | + */ | |
1191 | + vlan = batadv_softif_vlan_get(bat_priv, vid); | |
1192 | + if (vlan) { | |
1193 | + ap_isolation_enabled = atomic_read(&vlan->ap_isolation); | |
1194 | + batadv_softif_vlan_free_ref(vlan); | |
1195 | + } | |
1196 | + | |
1197 | + return ap_isolation_enabled; | |
1198 | +} | |
1199 | + | |
1174 | 1200 | static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) |
1175 | 1201 | { |
1176 | 1202 | struct batadv_algo_ops *bat_algo_ops; |
net/batman-adv/main.h
... | ... | @@ -369,6 +369,7 @@ |
369 | 369 | uint8_t *dst, uint8_t type, uint8_t version, |
370 | 370 | void *tvlv_value, uint16_t tvlv_value_len); |
371 | 371 | unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len); |
372 | +bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid); | |
372 | 373 | |
373 | 374 | #endif /* _NET_BATMAN_ADV_MAIN_H_ */ |
net/batman-adv/translation-table.c
... | ... | @@ -1900,19 +1900,8 @@ |
1900 | 1900 | struct batadv_tt_global_entry *tt_global_entry = NULL; |
1901 | 1901 | struct batadv_orig_node *orig_node = NULL; |
1902 | 1902 | struct batadv_tt_orig_list_entry *best_entry; |
1903 | - bool ap_isolation_enabled = false; | |
1904 | - struct batadv_softif_vlan *vlan; | |
1905 | 1903 | |
1906 | - /* if the AP isolation is requested on a VLAN, then check for its | |
1907 | - * setting in the proper VLAN private data structure | |
1908 | - */ | |
1909 | - vlan = batadv_softif_vlan_get(bat_priv, vid); | |
1910 | - if (vlan) { | |
1911 | - ap_isolation_enabled = atomic_read(&vlan->ap_isolation); | |
1912 | - batadv_softif_vlan_free_ref(vlan); | |
1913 | - } | |
1914 | - | |
1915 | - if (src && ap_isolation_enabled) { | |
1904 | + if (src && batadv_vlan_ap_isola_get(bat_priv, vid)) { | |
1916 | 1905 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, src, vid); |
1917 | 1906 | if (!tt_local_entry || |
1918 | 1907 | (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING)) |