summaryrefslogtreecommitdiffstats
path: root/net/ieee802154/6lowpan.c
Commit message (Collapse)AuthorAgeFilesLines
* 6lowpan: fix/move/cleanup debug functionsAlexander Aring2013-12-121-38/+5Star
| | | | | | | | | | | | There are several issues on current debug behaviour. This patch fix the following issues: - Fix debug printout only if DEBUG is defined. - Move debug functions of 6LoWPAN code into 6lowpan header. - Cleanup codestyle of debug functions. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* 6lowpan: Moving generic compression code into 6lowpan_iphc.cJukka Rissanen2013-12-111-718/+35Star
| | | | | | | | | | Because the IEEE 802154 and Bluetooth share the IP header compression and uncompression code, the common code is moved to 6lowpan_iphc.c file. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com> Acked-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
* 6lowpan: Uncompression of traffic class field was incorrectJukka Rissanen2013-11-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If priority/traffic class field in IPv6 header is set (seen when using ssh), the uncompression sets the TC and Flow fields incorrectly. Example: This is IPv6 header of a sent packet. Note the priority/TC (=1) in the first byte. 00000000: 61 00 00 00 00 2c 06 40 fe 80 00 00 00 00 00 00 00000010: 02 02 72 ff fe c6 42 10 fe 80 00 00 00 00 00 00 00000020: 02 1e ab ff fe 4c 52 57 This gets compressed like this in the sending side 00000000: 72 31 04 06 02 1e ab ff fe 4c 52 57 ec c2 00 16 00000010: aa 2d fe 92 86 4e be c6 .... In the receiving end, the packet gets uncompressed to this IPv6 header 00000000: 60 06 06 02 00 2a 1e 40 fe 80 00 00 00 00 00 00 00000010: 02 02 72 ff fe c6 42 10 fe 80 00 00 00 00 00 00 00000020: ab ff fe 4c 52 57 ec c2 First four bytes are set incorrectly and we have also lost two bytes from destination address. The fix is to switch the case values in switch statement when checking the TC field. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: release device on error pathDan Carpenter2013-11-081-1/+3
| | | | | | | | We recently added a new error path and it needs a dev_put(). Fixes: 7adac1ec8198 ('6lowpan: Only make 6lowpan links to IEEE802154 devices') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: cleanup skb copy dataAlexander Aring2013-10-301-5/+8
| | | | | | | | | This patch drops the direct memcpy on skb and uses the right skb memcpy functions. Also remove an unnecessary check if plen is non zero. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: set 6lowpan network and transport headerAlexander Aring2013-10-301-0/+2
| | | | | | | | | | | This is necessary to access network header with the skb_network_header function instead of calculate the position with mac_len, etc. Do the same for the transport header, when we replace the IPv6 header with the 6LoWPAN header. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Acked-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: set and use mac_len for mac header lengthAlexander Aring2013-10-301-12/+1Star
| | | | | | | | | | | Set the mac header length while creating the 802.15.4 mac header. Drop the function for recalculate mac header length in upper layers which was static and works for intra pan communication only. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: remove unnecessary set of headersAlexander Aring2013-10-301-4/+0Star
| | | | | | | | | | On receiving side we don't need to set any headers in skb because the 6LoWPAN layer do not access it. Currently these values will set twice after calling netif_rx. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: remove unnecessary breakAlexander Aring2013-10-291-1/+0Star
| | | | | | Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: remove skb->dev assignmentAlexander Aring2013-10-291-1/+0Star
| | | | | | | | | | This patch removes the assignment of skb->dev. We don't need it here because we use the netdev_alloc_skb_ip_align function which already sets the skb->dev. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: use netdev_alloc_skb instead dev_alloc_skbAlexander Aring2013-10-291-2/+2
| | | | | | | | | This patch uses the netdev_alloc_skb instead dev_alloc_skb function and drops the seperate assignment to skb->dev. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: remove unnecessary check on err >= 0Alexander Aring2013-10-291-1/+1
| | | | | | | | The err variable can only be zero in this case. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: remove unnecessary ret variableAlexander Aring2013-10-291-4/+2Star
| | | | | | Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Sync default hardware address of lowpan links to their wpanAlan Ott2013-10-081-0/+3
| | | | | | | | When a lowpan link to a wpan device is created, set the hardware address of the lowpan link to that of the wpan device. Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Only make 6lowpan links to IEEE802154 devicesAlan Ott2013-10-081-0/+2
| | | | | | | | | Refuse to create 6lowpan links if the actual hardware interface is of any type other than ARPHRD_IEEE802154. Signed-off-by: Alan Ott <alan@signal11.us> Suggested-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: handle context based source addressAlexander Aring2013-08-201-3/+46
| | | | | | | | | | Handle context based address when an unspecified address is given. For other context based address we print a warning and drop the packet because we don't support it right now. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: lowpan_uncompress_addr with address_modeAlexander Aring2013-08-201-68/+77
| | | | | | | | | | | | | | | | | | | | | | This patch drops the pre and postcount calculation from the lowpan_uncompress_addr function.We use instead a switch/case over address_mode value. The original implementation has several bugs in this function and it was hard to decrypt how it works. To make it maintainable and fix these bugs this patch basically reimplements lowpan_uncompress_addr from scratch. A list of bugs we found in the current implementation: 1) Properly support uncompression of short-address based IPv6 addresses (instead of basically copying garbage) 2) Fix use and uncompression of long-addresses based IPv6 addresses 3) Add missing ff:fe00 in the case of SAM/DAM = 2 and M = 0 Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: add function to uncompress multicast addrAlexander Aring2013-08-201-19/+59
| | | | | | | | | | | | | Add function to uncompress multicast address. This function split the uncompress function for a multicast address in a seperate function. To uncompress a multicast address is different than a other non-multicasts addresses according to rfc6282. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Fix fragmentation with link-local compressed addressesDavid Hauweele2013-08-201-0/+6
| | | | | | | | | | | | | | | | | | | When a new 6lowpan fragment is received, a skbuff is allocated for the reassembled packet. However when a 6lowpan packet compresses link-local addresses based on link-layer addresses, the processing function relies on the skb mac control block to find the related link-layer address. This patch copies the control block from the first fragment into the newly allocated skb to keep a trace of the link-layer addresses in case of a link-local compressed address. Edit: small changes on comment issue Signed-off-by: David Hauweele <david@hauweele.net> Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: init ipv6hdr buffer to zeroAlexander Aring2013-08-201-11/+1Star
| | | | | | | | | | | | | This patch simplify the handling to set fields inside of struct ipv6hdr to zero. Instead of setting some memory regions with memset to zero we initialize the whole ipv6hdr to zero. This is a simplification for parsing the 6lowpan header for the upcomming patches. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Reviewed-by: Werner Almesberger <werner@almesberger.net> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: pass info struct via netdevice notifierJiri Pirko2013-05-281-3/+2Star
| | | | | | | | | | | | | | So far, only net_device * could be passed along with netdevice notifier event. This patch provides a possibility to pass custom structure able to provide info that event listener needs to know. Signed-off-by: Jiri Pirko <jiri@resnulli.us> v2->v3: fix typo on simeth shortened dev_getter shortened notifier_info struct name v1->v2: fix notifier_call parameter in call_netdevice_notifier() Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: handle dev_queue_xmit() error code properlyAlan Ott2013-04-071-2/+2
| | | | | | | | | | | dev_queue_xmit() will return a positive value if the packet could not be queued, often because the real network device (in our case the mac802154 wpan device) has its queue stopped. lowpan_xmit() should handle the positive return code (for the debug statement) and return that value to the higher layer so the higher layer will retry sending the packet. Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: use IEEE802154_ADDR_LEN instead of a magic numberTony Cheneau2013-03-271-1/+1
| | | | | Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: fix a small formatting issueTony Cheneau2013-03-271-1/+1
| | | | | | | | This formatting issue was introduced with commit d4ac32365dcbfd341a87eae444c26679f889249a Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: modify udp compression/uncompression to match the standardTony Cheneau2013-03-261-3/+36
| | | | | | | | The previous code would just compress the UDP header and send the compressed UDP header along with the uncompressed one. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: use the PANID provided by the device instead of a static valueTony Cheneau2013-03-261-2/+4
| | | | | Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: obtain IEEE802.15.4 sequence number from the MAC layerTony Cheneau2013-03-261-0/+8
| | | | | | | | Sets the sequence number in the frame format. Without this fix, the sequence number is always set to 0. This makes trafic analysis very hard. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: store fragment tag values per device instead of net stack wideTony Cheneau2013-03-261-4/+5
| | | | | Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: add debug messages for 6LoWPAN fragmentationTony Cheneau2013-03-261-4/+21
| | | | | | | | Add pr_debug() call in order to debug 6LoWPAN fragmentation and reassembly. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: fix first fragment (FRAG1) handlingTony Cheneau2013-03-261-13/+23
| | | | | | | | | | | | | | | | The first fragment, FRAG1, must contain some payload according to the specs. However, as it is currently written, the first fragment will remain empty and only contain the 6lowpan headers. This patch also extracts the transport layer information from the first fragment. This information is used later on when uncompressing UDP header. Thanks to Wolf-Bastian Pöttner for noticing that the offset value was not properly initialized. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: use short IEEE 802.15.4 addresses for broadcast destinationTony Cheneau2013-03-261-8/+15
| | | | | | | | The IEEE 802.15.4 standard uses the 0xFFFF short address (2 bytes) for message broadcasting. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: always enable link-layer acknowledgmentsTony Cheneau2013-03-261-0/+4
| | | | | | | | | | | This feature is especially important when using fragmentation, because the reassembly mechanism cannot recover from the loss of a fragment. Note that some hardware ignore this flag and not will not transmit acknowledgments even if this is set. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: next header is not properly set upon decompression of a UDP header.Tony Cheneau2013-03-261-1/+3
| | | | | | | This causes a drop of the UDP packet. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: use stack buffer instead of heapAlexander Aring2013-02-061-9/+4Star
| | | | | | | | | | head buffer is only temporary available in lowpan_header_create. So it's not necessary to put it on the heap. Also fixed a comment codestyle issue. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Remove __init tag from lowpan_netlink_fini().David S. Miller2013-02-061-1/+1
| | | | | | | It's called from both __init and __exit code, so neither tag is appropriate. Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Handle uncompressed IPv6 packets over 6LoWPANAlan Ott2013-01-181-9/+32
| | | | | | | Handle the reception of uncompressed packets (dispatch type = IPv6). Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Refactor packet delivery into a functionAlan Ott2013-01-181-14/+24
| | | | | | | | Refactor the handing of the skb's to the individual lowpan devices into a function. Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: consider checksum bytes in fragmentation thresholdAlan Ott2012-11-301-1/+2
| | | | | | | | | | Change the threshold for framentation of a lowpan packet from using the MTU size to now use the MTU size minus the checksum length, which is added by the hardware. For IEEE 802.15.4, this effectively changes it from 127 bytes to 125 bytes. Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@davemloft.net>
* net/ieee802154/6lowpan.c: Remove unecessary semicolonPeter Senna Tschudin2012-09-181-1/+1
| | | | | | | Found by http://coccinelle.lip6.fr/ Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: handle NETDEV_UNREGISTER eventAlan Ott2012-09-021-7/+37
| | | | | | | | Before, it was impossible to remove a wpan device which had lowpan attached to it. Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@tempietto.lan>
* 6lowpan: Make a copy of skb's delivered to 6lowpanAlan Ott2012-09-021-1/+8
| | | | | | | | | Since lowpan_process_data() modifies the skb (by calling skb_pull()), we need our own copy so that it doesn't affect the data received by other protcols (in this case, af_ieee802154). Signed-off-by: Alan Ott <alan@signal11.us> Signed-off-by: David S. Miller <davem@tempietto.lan>
* 6lowpan: Change byte order when storing/accessing to len fieldTony Cheneau2012-07-171-8/+12
| | | | | | | | | | Lenght field should be encoded using big endian byte order, such as intend in the specs. As it is currently written, the len field would not be decoded properly on an implementation using the correct byte ordering. Hence, it could lead to interroperability issues. Also, I rewrote the code so that iphc0 argument of lowpan_alloc_new_frame could be removed. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Change byte order when storing/accessing u16 tagTony Cheneau2012-07-171-3/+3
| | | | | | | | | | The tag field should be stored and accessed using big endian byte order (as intended in the specs). Or else, when displayed with a trafic analyser, such a Wireshark, the field not properly displayed (e.g. 0x01 00 instead of 0x00 01, and so on). Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: Fix null pointer dereference in UDP uncompression functionTony Cheneau2012-07-171-0/+3
| | | | | | | | | | When a UDP packet gets fragmented, a crash will occur at reassembly time. This is because skb->transport_header is not set during earlier period of fragment reassembly. As a consequence, call to udp_hdr() return NULL and uh (which is NULL) gets dereferenced without much test. Signed-off-by: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: rework fragment-deleting routinealex.bluesman.smirnov@gmail.com2012-07-121-19/+20
| | | | | | | | | | | | | 6lowpan module starts collecting incomming frames and fragments right after lowpan_module_init() therefor it will be better to clean unfinished fragments in lowpan_cleanup_module() function instead of doing it when link goes down. Changed spinlocks type to prevent deadlock with expired timer event and removed unused one. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: fix tag variable sizealex.bluesman.smirnov@gmail.com2012-07-121-1/+1
| | | | | | | | | | | Function lowpan_alloc_new_frame() takes u8 tag as an argument. However, its only caller, lowpan_process_data() passes down a u16. Hence, the tag value can get corrupted. This prevent 6lowpan fragment reassembly of a message when the fragment tag value is over 256. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Cc: Tony Cheneau <tony.cheneau@amnesiak.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: get extra headroom in allocated framealex.bluesman.smirnov@gmail.com2012-07-121-2/+2
| | | | | | | | | Use netdev_alloc_skb_ip_align() instead of alloc_skb() to get some extra headroom in case we need to forward this frame in a tunnel or something else. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: revert: add missing spin_lock_init()alex.bluesman.smirnov@gmail.com2012-07-121-3/+1Star
| | | | | | | | | Revert the commit 768f7c7c121e80f458a9d013b2e8b169e5dfb1e5 to initialize spinlock in the more preferable way and make it static to avoid sparse warning. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: revert 'reuse eth_mac_addr()'alex.bluesman.smirnov@gmail.com2012-07-051-2/+14
| | | | | | | | | | | | This reverts the commit cdf49c283e2e105da86ca575ad35b453f5ff24ea which replaces lowpan '.ndo_set_mac_address' method by ethernet's one. Accorind to the IEEE 802.15.4 standard, device has 8-byte length address, so this hook loses the last 2 bytes which may rise a compatibility problems with other IEEE 802.15.4 standard implementations. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* 6lowpan: double unlock on an error pathDan Carpenter2012-06-271-1/+1
| | | | | | | | | | We already unlocked a few lines earlier here, so we can go directly to drop without passing through unlock. This was introduced recently in c5d3687f6c ('6lowpan: read data from skb safely'). Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>