diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2012-03-04 03:56:25 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-05-11 04:08:11 -0400 |
commit | c3e29312c8c27d403f91522711ce9a290c7571c9 (patch) | |
tree | a366ebef6e2d65ed5fdbec48e38fc3e630a9e367 /net/batman-adv/bat_iv_ogm.c | |
parent | ffa995e036bef734ea40cbbccda574d1df3a8a58 (diff) |
batman-adv: register batman ogm receive function during protocol init
The B.A.T.M.A.N. IV OGM receive function still was hard-coded although
it is a routing protocol specific function. This patch takes advantage
of the dynamic packet handler registration to remove the hard-coded
function calls.
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index cd8f473c1bd0..e0aaf8c87d65 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -1155,13 +1155,18 @@ out: | |||
1155 | orig_node_free_ref(orig_node); | 1155 | orig_node_free_ref(orig_node); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | static void bat_iv_ogm_receive(struct hard_iface *if_incoming, | 1158 | static int bat_iv_ogm_receive(struct sk_buff *skb, |
1159 | struct sk_buff *skb) | 1159 | struct hard_iface *if_incoming) |
1160 | { | 1160 | { |
1161 | struct batman_ogm_packet *batman_ogm_packet; | 1161 | struct batman_ogm_packet *batman_ogm_packet; |
1162 | struct ethhdr *ethhdr; | 1162 | struct ethhdr *ethhdr; |
1163 | int buff_pos = 0, packet_len; | 1163 | int buff_pos = 0, packet_len; |
1164 | unsigned char *tt_buff, *packet_buff; | 1164 | unsigned char *tt_buff, *packet_buff; |
1165 | bool ret; | ||
1166 | |||
1167 | ret = check_management_packet(skb, if_incoming, BATMAN_OGM_HLEN); | ||
1168 | if (!ret) | ||
1169 | return NET_RX_DROP; | ||
1165 | 1170 | ||
1166 | packet_len = skb_headlen(skb); | 1171 | packet_len = skb_headlen(skb); |
1167 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1172 | ethhdr = (struct ethhdr *)skb_mac_header(skb); |
@@ -1187,6 +1192,9 @@ static void bat_iv_ogm_receive(struct hard_iface *if_incoming, | |||
1187 | (packet_buff + buff_pos); | 1192 | (packet_buff + buff_pos); |
1188 | } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, | 1193 | } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, |
1189 | batman_ogm_packet->tt_num_changes)); | 1194 | batman_ogm_packet->tt_num_changes)); |
1195 | |||
1196 | kfree_skb(skb); | ||
1197 | return NET_RX_SUCCESS; | ||
1190 | } | 1198 | } |
1191 | 1199 | ||
1192 | static struct bat_algo_ops batman_iv __read_mostly = { | 1200 | static struct bat_algo_ops batman_iv __read_mostly = { |
@@ -1197,10 +1205,25 @@ static struct bat_algo_ops batman_iv __read_mostly = { | |||
1197 | .bat_ogm_update_mac = bat_iv_ogm_update_mac, | 1205 | .bat_ogm_update_mac = bat_iv_ogm_update_mac, |
1198 | .bat_ogm_schedule = bat_iv_ogm_schedule, | 1206 | .bat_ogm_schedule = bat_iv_ogm_schedule, |
1199 | .bat_ogm_emit = bat_iv_ogm_emit, | 1207 | .bat_ogm_emit = bat_iv_ogm_emit, |
1200 | .bat_ogm_receive = bat_iv_ogm_receive, | ||
1201 | }; | 1208 | }; |
1202 | 1209 | ||
1203 | int __init bat_iv_init(void) | 1210 | int __init bat_iv_init(void) |
1204 | { | 1211 | { |
1205 | return bat_algo_register(&batman_iv); | 1212 | int ret; |
1213 | |||
1214 | /* batman originator packet */ | ||
1215 | ret = recv_handler_register(BAT_IV_OGM, bat_iv_ogm_receive); | ||
1216 | if (ret < 0) | ||
1217 | goto out; | ||
1218 | |||
1219 | ret = bat_algo_register(&batman_iv); | ||
1220 | if (ret < 0) | ||
1221 | goto handler_unregister; | ||
1222 | |||
1223 | goto out; | ||
1224 | |||
1225 | handler_unregister: | ||
1226 | recv_handler_unregister(BAT_IV_OGM); | ||
1227 | out: | ||
1228 | return ret; | ||
1206 | } | 1229 | } |