hard-interface.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*
  2. * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. #include "main.h"
  22. #include "hard-interface.h"
  23. #include "soft-interface.h"
  24. #include "send.h"
  25. #include "translation-table.h"
  26. #include "routing.h"
  27. #include "bat_sysfs.h"
  28. #include "originator.h"
  29. #include "hash.h"
  30. #include <linux/if_arp.h>
  31. static int batman_skb_recv(struct sk_buff *skb,
  32. struct net_device *dev,
  33. struct packet_type *ptype,
  34. struct net_device *orig_dev);
  35. void hardif_free_rcu(struct rcu_head *rcu)
  36. {
  37. struct hard_iface *hard_iface;
  38. hard_iface = container_of(rcu, struct hard_iface, rcu);
  39. dev_put(hard_iface->net_dev);
  40. kfree(hard_iface);
  41. }
  42. struct hard_iface *hardif_get_by_netdev(const struct net_device *net_dev)
  43. {
  44. struct hard_iface *hard_iface;
  45. rcu_read_lock();
  46. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  47. if (hard_iface->net_dev == net_dev &&
  48. atomic_inc_not_zero(&hard_iface->refcount))
  49. goto out;
  50. }
  51. hard_iface = NULL;
  52. out:
  53. rcu_read_unlock();
  54. return hard_iface;
  55. }
  56. static int is_valid_iface(const struct net_device *net_dev)
  57. {
  58. if (net_dev->flags & IFF_LOOPBACK)
  59. return 0;
  60. if (net_dev->type != ARPHRD_ETHER)
  61. return 0;
  62. if (net_dev->addr_len != ETH_ALEN)
  63. return 0;
  64. /* no batman over batman */
  65. if (softif_is_valid(net_dev))
  66. return 0;
  67. /* Device is being bridged */
  68. /* if (net_dev->priv_flags & IFF_BRIDGE_PORT)
  69. return 0; */
  70. return 1;
  71. }
  72. static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
  73. {
  74. struct hard_iface *hard_iface;
  75. rcu_read_lock();
  76. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  77. if (hard_iface->soft_iface != soft_iface)
  78. continue;
  79. if (hard_iface->if_status == IF_ACTIVE &&
  80. atomic_inc_not_zero(&hard_iface->refcount))
  81. goto out;
  82. }
  83. hard_iface = NULL;
  84. out:
  85. rcu_read_unlock();
  86. return hard_iface;
  87. }
  88. static void primary_if_update_addr(struct bat_priv *bat_priv)
  89. {
  90. struct vis_packet *vis_packet;
  91. struct hard_iface *primary_if;
  92. primary_if = primary_if_get_selected(bat_priv);
  93. if (!primary_if)
  94. goto out;
  95. vis_packet = (struct vis_packet *)
  96. bat_priv->my_vis_info->skb_packet->data;
  97. memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
  98. memcpy(vis_packet->sender_orig,
  99. primary_if->net_dev->dev_addr, ETH_ALEN);
  100. out:
  101. if (primary_if)
  102. hardif_free_ref(primary_if);
  103. }
  104. static void primary_if_select(struct bat_priv *bat_priv,
  105. struct hard_iface *new_hard_iface)
  106. {
  107. struct hard_iface *curr_hard_iface;
  108. struct batman_packet *batman_packet;
  109. ASSERT_RTNL();
  110. if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
  111. new_hard_iface = NULL;
  112. curr_hard_iface = rcu_dereference_protected(bat_priv->primary_if, 1);
  113. rcu_assign_pointer(bat_priv->primary_if, new_hard_iface);
  114. if (curr_hard_iface)
  115. hardif_free_ref(curr_hard_iface);
  116. if (!new_hard_iface)
  117. return;
  118. batman_packet = (struct batman_packet *)(new_hard_iface->packet_buff);
  119. batman_packet->flags = PRIMARIES_FIRST_HOP;
  120. batman_packet->ttl = TTL;
  121. primary_if_update_addr(bat_priv);
  122. }
  123. static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
  124. {
  125. if (hard_iface->net_dev->flags & IFF_UP)
  126. return true;
  127. return false;
  128. }
  129. static void update_mac_addresses(struct hard_iface *hard_iface)
  130. {
  131. memcpy(((struct batman_packet *)(hard_iface->packet_buff))->orig,
  132. hard_iface->net_dev->dev_addr, ETH_ALEN);
  133. memcpy(((struct batman_packet *)(hard_iface->packet_buff))->prev_sender,
  134. hard_iface->net_dev->dev_addr, ETH_ALEN);
  135. }
  136. static void check_known_mac_addr(const struct net_device *net_dev)
  137. {
  138. const struct hard_iface *hard_iface;
  139. rcu_read_lock();
  140. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  141. if ((hard_iface->if_status != IF_ACTIVE) &&
  142. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  143. continue;
  144. if (hard_iface->net_dev == net_dev)
  145. continue;
  146. if (!compare_eth(hard_iface->net_dev->dev_addr,
  147. net_dev->dev_addr))
  148. continue;
  149. pr_warning("The newly added mac address (%pM) already exists "
  150. "on: %s\n", net_dev->dev_addr,
  151. hard_iface->net_dev->name);
  152. pr_warning("It is strongly recommended to keep mac addresses "
  153. "unique to avoid problems!\n");
  154. }
  155. rcu_read_unlock();
  156. }
  157. int hardif_min_mtu(struct net_device *soft_iface)
  158. {
  159. const struct bat_priv *bat_priv = netdev_priv(soft_iface);
  160. const struct hard_iface *hard_iface;
  161. /* allow big frames if all devices are capable to do so
  162. * (have MTU > 1500 + BAT_HEADER_LEN) */
  163. int min_mtu = ETH_DATA_LEN;
  164. if (atomic_read(&bat_priv->fragmentation))
  165. goto out;
  166. rcu_read_lock();
  167. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  168. if ((hard_iface->if_status != IF_ACTIVE) &&
  169. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  170. continue;
  171. if (hard_iface->soft_iface != soft_iface)
  172. continue;
  173. min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN,
  174. min_mtu);
  175. }
  176. rcu_read_unlock();
  177. out:
  178. return min_mtu;
  179. }
  180. /* adjusts the MTU if a new interface with a smaller MTU appeared. */
  181. void update_min_mtu(struct net_device *soft_iface)
  182. {
  183. int min_mtu;
  184. min_mtu = hardif_min_mtu(soft_iface);
  185. if (soft_iface->mtu != min_mtu)
  186. soft_iface->mtu = min_mtu;
  187. }
  188. static void hardif_activate_interface(struct hard_iface *hard_iface)
  189. {
  190. struct bat_priv *bat_priv;
  191. struct hard_iface *primary_if = NULL;
  192. if (hard_iface->if_status != IF_INACTIVE)
  193. goto out;
  194. bat_priv = netdev_priv(hard_iface->soft_iface);
  195. update_mac_addresses(hard_iface);
  196. hard_iface->if_status = IF_TO_BE_ACTIVATED;
  197. /**
  198. * the first active interface becomes our primary interface or
  199. * the next active interface after the old primay interface was removed
  200. */
  201. primary_if = primary_if_get_selected(bat_priv);
  202. if (!primary_if)
  203. primary_if_select(bat_priv, hard_iface);
  204. bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
  205. hard_iface->net_dev->name);
  206. update_min_mtu(hard_iface->soft_iface);
  207. out:
  208. if (primary_if)
  209. hardif_free_ref(primary_if);
  210. }
  211. static void hardif_deactivate_interface(struct hard_iface *hard_iface)
  212. {
  213. if ((hard_iface->if_status != IF_ACTIVE) &&
  214. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  215. return;
  216. hard_iface->if_status = IF_INACTIVE;
  217. bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
  218. hard_iface->net_dev->name);
  219. update_min_mtu(hard_iface->soft_iface);
  220. }
  221. int hardif_enable_interface(struct hard_iface *hard_iface,
  222. const char *iface_name)
  223. {
  224. struct bat_priv *bat_priv;
  225. struct batman_packet *batman_packet;
  226. struct net_device *soft_iface;
  227. int ret;
  228. if (hard_iface->if_status != IF_NOT_IN_USE)
  229. goto out;
  230. if (!atomic_inc_not_zero(&hard_iface->refcount))
  231. goto out;
  232. soft_iface = dev_get_by_name(&init_net, iface_name);
  233. if (!soft_iface) {
  234. soft_iface = softif_create(iface_name);
  235. if (!soft_iface) {
  236. ret = -ENOMEM;
  237. goto err;
  238. }
  239. /* dev_get_by_name() increases the reference counter for us */
  240. dev_hold(soft_iface);
  241. }
  242. if (!softif_is_valid(soft_iface)) {
  243. pr_err("Can't create batman mesh interface %s: "
  244. "already exists as regular interface\n",
  245. soft_iface->name);
  246. dev_put(soft_iface);
  247. ret = -EINVAL;
  248. goto err;
  249. }
  250. hard_iface->soft_iface = soft_iface;
  251. bat_priv = netdev_priv(hard_iface->soft_iface);
  252. hard_iface->packet_len = BAT_PACKET_LEN;
  253. hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
  254. if (!hard_iface->packet_buff) {
  255. bat_err(hard_iface->soft_iface, "Can't add interface packet "
  256. "(%s): out of memory\n", hard_iface->net_dev->name);
  257. ret = -ENOMEM;
  258. goto err;
  259. }
  260. batman_packet = (struct batman_packet *)(hard_iface->packet_buff);
  261. batman_packet->packet_type = BAT_PACKET;
  262. batman_packet->version = COMPAT_VERSION;
  263. batman_packet->flags = NO_FLAGS;
  264. batman_packet->ttl = 2;
  265. batman_packet->tq = TQ_MAX_VALUE;
  266. batman_packet->tt_num_changes = 0;
  267. batman_packet->ttvn = 0;
  268. hard_iface->if_num = bat_priv->num_ifaces;
  269. bat_priv->num_ifaces++;
  270. hard_iface->if_status = IF_INACTIVE;
  271. orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
  272. hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN);
  273. hard_iface->batman_adv_ptype.func = batman_skb_recv;
  274. hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
  275. dev_add_pack(&hard_iface->batman_adv_ptype);
  276. atomic_set(&hard_iface->seqno, 1);
  277. atomic_set(&hard_iface->frag_seqno, 1);
  278. bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
  279. hard_iface->net_dev->name);
  280. if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  281. ETH_DATA_LEN + BAT_HEADER_LEN)
  282. bat_info(hard_iface->soft_iface,
  283. "The MTU of interface %s is too small (%i) to handle "
  284. "the transport of batman-adv packets. Packets going "
  285. "over this interface will be fragmented on layer2 "
  286. "which could impact the performance. Setting the MTU "
  287. "to %zi would solve the problem.\n",
  288. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  289. ETH_DATA_LEN + BAT_HEADER_LEN);
  290. if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  291. ETH_DATA_LEN + BAT_HEADER_LEN)
  292. bat_info(hard_iface->soft_iface,
  293. "The MTU of interface %s is too small (%i) to handle "
  294. "the transport of batman-adv packets. If you experience"
  295. " problems getting traffic through try increasing the "
  296. "MTU to %zi.\n",
  297. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  298. ETH_DATA_LEN + BAT_HEADER_LEN);
  299. if (hardif_is_iface_up(hard_iface))
  300. hardif_activate_interface(hard_iface);
  301. else
  302. bat_err(hard_iface->soft_iface, "Not using interface %s "
  303. "(retrying later): interface not active\n",
  304. hard_iface->net_dev->name);
  305. /* begin scheduling originator messages on that interface */
  306. schedule_own_packet(hard_iface);
  307. out:
  308. return 0;
  309. err:
  310. hardif_free_ref(hard_iface);
  311. return ret;
  312. }
  313. void hardif_disable_interface(struct hard_iface *hard_iface)
  314. {
  315. struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
  316. struct hard_iface *primary_if = NULL;
  317. if (hard_iface->if_status == IF_ACTIVE)
  318. hardif_deactivate_interface(hard_iface);
  319. if (hard_iface->if_status != IF_INACTIVE)
  320. goto out;
  321. bat_info(hard_iface->soft_iface, "Removing interface: %s\n",
  322. hard_iface->net_dev->name);
  323. dev_remove_pack(&hard_iface->batman_adv_ptype);
  324. bat_priv->num_ifaces--;
  325. orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
  326. primary_if = primary_if_get_selected(bat_priv);
  327. if (hard_iface == primary_if) {
  328. struct hard_iface *new_if;
  329. new_if = hardif_get_active(hard_iface->soft_iface);
  330. primary_if_select(bat_priv, new_if);
  331. if (new_if)
  332. hardif_free_ref(new_if);
  333. }
  334. kfree(hard_iface->packet_buff);
  335. hard_iface->packet_buff = NULL;
  336. hard_iface->if_status = IF_NOT_IN_USE;
  337. /* delete all references to this hard_iface */
  338. purge_orig_ref(bat_priv);
  339. purge_outstanding_packets(bat_priv, hard_iface);
  340. dev_put(hard_iface->soft_iface);
  341. /* nobody uses this interface anymore */
  342. if (!bat_priv->num_ifaces)
  343. softif_destroy(hard_iface->soft_iface);
  344. hard_iface->soft_iface = NULL;
  345. hardif_free_ref(hard_iface);
  346. out:
  347. if (primary_if)
  348. hardif_free_ref(primary_if);
  349. }
  350. static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
  351. {
  352. struct hard_iface *hard_iface;
  353. int ret;
  354. ASSERT_RTNL();
  355. ret = is_valid_iface(net_dev);
  356. if (ret != 1)
  357. goto out;
  358. dev_hold(net_dev);
  359. hard_iface = kmalloc(sizeof(*hard_iface), GFP_ATOMIC);
  360. if (!hard_iface) {
  361. pr_err("Can't add interface (%s): out of memory\n",
  362. net_dev->name);
  363. goto release_dev;
  364. }
  365. ret = sysfs_add_hardif(&hard_iface->hardif_obj, net_dev);
  366. if (ret)
  367. goto free_if;
  368. hard_iface->if_num = -1;
  369. hard_iface->net_dev = net_dev;
  370. hard_iface->soft_iface = NULL;
  371. hard_iface->if_status = IF_NOT_IN_USE;
  372. INIT_LIST_HEAD(&hard_iface->list);
  373. /* extra reference for return */
  374. atomic_set(&hard_iface->refcount, 2);
  375. check_known_mac_addr(hard_iface->net_dev);
  376. list_add_tail_rcu(&hard_iface->list, &hardif_list);
  377. return hard_iface;
  378. free_if:
  379. kfree(hard_iface);
  380. release_dev:
  381. dev_put(net_dev);
  382. out:
  383. return NULL;
  384. }
  385. static void hardif_remove_interface(struct hard_iface *hard_iface)
  386. {
  387. ASSERT_RTNL();
  388. /* first deactivate interface */
  389. if (hard_iface->if_status != IF_NOT_IN_USE)
  390. hardif_disable_interface(hard_iface);
  391. if (hard_iface->if_status != IF_NOT_IN_USE)
  392. return;
  393. hard_iface->if_status = IF_TO_BE_REMOVED;
  394. sysfs_del_hardif(&hard_iface->hardif_obj);
  395. hardif_free_ref(hard_iface);
  396. }
  397. void hardif_remove_interfaces(void)
  398. {
  399. struct hard_iface *hard_iface, *hard_iface_tmp;
  400. rtnl_lock();
  401. list_for_each_entry_safe(hard_iface, hard_iface_tmp,
  402. &hardif_list, list) {
  403. list_del_rcu(&hard_iface->list);
  404. hardif_remove_interface(hard_iface);
  405. }
  406. rtnl_unlock();
  407. }
  408. static int hard_if_event(struct notifier_block *this,
  409. unsigned long event, void *ptr)
  410. {
  411. struct net_device *net_dev = ptr;
  412. struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
  413. struct hard_iface *primary_if = NULL;
  414. struct bat_priv *bat_priv;
  415. if (!hard_iface && event == NETDEV_REGISTER)
  416. hard_iface = hardif_add_interface(net_dev);
  417. if (!hard_iface)
  418. goto out;
  419. switch (event) {
  420. case NETDEV_UP:
  421. hardif_activate_interface(hard_iface);
  422. break;
  423. case NETDEV_GOING_DOWN:
  424. case NETDEV_DOWN:
  425. hardif_deactivate_interface(hard_iface);
  426. break;
  427. case NETDEV_UNREGISTER:
  428. list_del_rcu(&hard_iface->list);
  429. hardif_remove_interface(hard_iface);
  430. break;
  431. case NETDEV_CHANGEMTU:
  432. if (hard_iface->soft_iface)
  433. update_min_mtu(hard_iface->soft_iface);
  434. break;
  435. case NETDEV_CHANGEADDR:
  436. if (hard_iface->if_status == IF_NOT_IN_USE)
  437. goto hardif_put;
  438. check_known_mac_addr(hard_iface->net_dev);
  439. update_mac_addresses(hard_iface);
  440. bat_priv = netdev_priv(hard_iface->soft_iface);
  441. primary_if = primary_if_get_selected(bat_priv);
  442. if (!primary_if)
  443. goto hardif_put;
  444. if (hard_iface == primary_if)
  445. primary_if_update_addr(bat_priv);
  446. break;
  447. default:
  448. break;
  449. }
  450. hardif_put:
  451. hardif_free_ref(hard_iface);
  452. out:
  453. if (primary_if)
  454. hardif_free_ref(primary_if);
  455. return NOTIFY_DONE;
  456. }
  457. /* receive a packet with the batman ethertype coming on a hard
  458. * interface */
  459. static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
  460. struct packet_type *ptype,
  461. struct net_device *orig_dev)
  462. {
  463. struct bat_priv *bat_priv;
  464. struct batman_packet *batman_packet;
  465. struct hard_iface *hard_iface;
  466. int ret;
  467. hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype);
  468. skb = skb_share_check(skb, GFP_ATOMIC);
  469. /* skb was released by skb_share_check() */
  470. if (!skb)
  471. goto err_out;
  472. /* packet should hold at least type and version */
  473. if (unlikely(!pskb_may_pull(skb, 2)))
  474. goto err_free;
  475. /* expect a valid ethernet header here. */
  476. if (unlikely(skb->mac_len != sizeof(struct ethhdr)
  477. || !skb_mac_header(skb)))
  478. goto err_free;
  479. if (!hard_iface->soft_iface)
  480. goto err_free;
  481. bat_priv = netdev_priv(hard_iface->soft_iface);
  482. if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
  483. goto err_free;
  484. /* discard frames on not active interfaces */
  485. if (hard_iface->if_status != IF_ACTIVE)
  486. goto err_free;
  487. batman_packet = (struct batman_packet *)skb->data;
  488. if (batman_packet->version != COMPAT_VERSION) {
  489. bat_dbg(DBG_BATMAN, bat_priv,
  490. "Drop packet: incompatible batman version (%i)\n",
  491. batman_packet->version);
  492. goto err_free;
  493. }
  494. /* all receive handlers return whether they received or reused
  495. * the supplied skb. if not, we have to free the skb. */
  496. switch (batman_packet->packet_type) {
  497. /* batman originator packet */
  498. case BAT_PACKET:
  499. ret = recv_bat_packet(skb, hard_iface);
  500. break;
  501. /* batman icmp packet */
  502. case BAT_ICMP:
  503. ret = recv_icmp_packet(skb, hard_iface);
  504. break;
  505. /* unicast packet */
  506. case BAT_UNICAST:
  507. ret = recv_unicast_packet(skb, hard_iface);
  508. break;
  509. /* fragmented unicast packet */
  510. case BAT_UNICAST_FRAG:
  511. ret = recv_ucast_frag_packet(skb, hard_iface);
  512. break;
  513. /* broadcast packet */
  514. case BAT_BCAST:
  515. ret = recv_bcast_packet(skb, hard_iface);
  516. break;
  517. /* vis packet */
  518. case BAT_VIS:
  519. ret = recv_vis_packet(skb, hard_iface);
  520. break;
  521. /* Translation table query (request or response) */
  522. case BAT_TT_QUERY:
  523. ret = recv_tt_query(skb, hard_iface);
  524. break;
  525. /* Roaming advertisement */
  526. case BAT_ROAM_ADV:
  527. ret = recv_roam_adv(skb, hard_iface);
  528. break;
  529. default:
  530. ret = NET_RX_DROP;
  531. }
  532. if (ret == NET_RX_DROP)
  533. kfree_skb(skb);
  534. /* return NET_RX_SUCCESS in any case as we
  535. * most probably dropped the packet for
  536. * routing-logical reasons. */
  537. return NET_RX_SUCCESS;
  538. err_free:
  539. kfree_skb(skb);
  540. err_out:
  541. return NET_RX_DROP;
  542. }
  543. struct notifier_block hard_if_notifier = {
  544. .notifier_call = hard_if_event,
  545. };