gnrc_netif2: Introduction of a new GNRC network interface API#7370
Conversation
|
d848738 to
e5ffd7e
Compare
|
Done with the implementation (I hope ^^). Now some unittests are missing. The stack integration and shell command I would prefer to do in a separate PR, since this PR already is quite large... |
e5ffd7e to
732bf5b
Compare
db3cc0a to
0ac7db2
Compare
|
(no longer WIP btw) |
sys/include/net/gnrc/netif2.h
Outdated
| * @param[in] netif The network interface. | ||
| * | ||
| * This is called after the default settings were set, right before the | ||
| * interface's thread starts receiving messages. It is not necessary lock |
There was a problem hiding this comment.
'It doesn't necessary lock'
There was a problem hiding this comment.
What? That doesn't make any sense.
There was a problem hiding this comment.
'It is not necessary lock the interface's mutex gnrc_netif_t::mutex, since the thread will already lock it.'
I think there's a typo here, that's why I proposed:
'It doesn't necessary lock...'
Maybe some rephrasing is required.
There was a problem hiding this comment.
But that negates the the sentence... Lock in is not required, since the thread will do that.
There was a problem hiding this comment.
*locking
Mh... But if I wrote it like you quoted me (can't check, am on a phone), then a "to" is missing. Will fix if it is so.
There was a problem hiding this comment.
"It doesn't necessary..." is in any way grammatically wrong ;)
sys/include/net/gnrc/netif2.h
Outdated
| * | ||
| * @return The number of bytes actually sent on success | ||
| * @return -EBADMSG, if the @ref net_gnrc_netif_hdr in @p pkt is missing | ||
| * or of an unexpected format. |
There was a problem hiding this comment.
'or is in an unexpected format' ?
sys/include/net/gnrc/netif2.h
Outdated
| * | ||
| * @pre `netif != NULL` | ||
| * | ||
| * @note The function takes the bytes received from via |
sys/include/net/gnrc/netif2.h
Outdated
| int (*get)(gnrc_netif2_t *netif, gnrc_netapi_opt_t *opt); | ||
|
|
||
| /** | ||
| * @brief Get an option from the network interface |
There was a problem hiding this comment.
Should be 'Sets an option' ?
Next line should also be updated.
sys/include/net/gnrc/netif2.h
Outdated
| gnrc_pktsnip_t *(*recv)(gnrc_netif2_t *netif); | ||
|
|
||
| /** | ||
| * @brief Get an option from the network interface |
sys/include/net/gnrc/netif2/conf.h
Outdated
| #endif | ||
|
|
||
| /** | ||
| * @brief Number of multicast addressed needed for @ref net_gnrc_rpl "RPL". |
| const ipv6_addr_t *addr); | ||
|
|
||
| /** | ||
| * @brief Get state from address flags |
There was a problem hiding this comment.
Gets ? This is no consistent in other places as well.
|
Addressed @aabadie's comments. |
c40338f to
943aab0
Compare
|
Rebased |
f2d599b to
d53ffd3
Compare
bergzand
left a comment
There was a problem hiding this comment.
Not a lot of technical remarks, mostly spelling and/or grammar related comments.
If I've got the time later today, I'd like to look a bit better at gnrc_netif2.c.
sys/include/net/gnrc/netif2.h
Outdated
| * | ||
| * @note The function re-formats the content of @p pkt to a format expected | ||
| * by the netdev_driver_t::send() method of gnrc_netif_t::dev and | ||
| * releases the it before returning (so no additional release should |
There was a problem hiding this comment.
"...releases the packet before..."
| * | ||
| * @return @p out. | ||
| */ | ||
| char *gnrc_netif2_addr_to_str(const uint8_t *addr, size_t addr_len, char *out); |
There was a problem hiding this comment.
Does it make sense here to return an input parameter? Why not return the size of the formatted string?
There was a problem hiding this comment.
strings are usually \0 terminate, so returning its length is not required (a non-fitting out is an error case) (this function is mostly used for debugging, so no machine short-cuts required).
sys/include/net/gnrc/netif2/conf.h
Outdated
| /** | ||
| * @brief Maximum number of network interfaces | ||
| * | ||
| * @note Intentially not calling it `GNRC_NETIF2_NUMOF` to not require |
| #define GNRC_NETIF2_L2ADDR_MAXLEN (IEEE802154_LONG_ADDRESS_LEN) | ||
| #elif MODULE_NETDEV_ETH | ||
| #define GNRC_NETIF2_L2ADDR_MAXLEN (ETHERNET_ADDR_LEN) | ||
| #elif MODULE_CC110X |
There was a problem hiding this comment.
It feels ugly to me to have a switch depending directly on a device driver. I don't know if there is a better solution for this though.
| * @attention GHC not implemented yet | ||
| * @see [RFC 7400, section 3.3](https://tools.ietf.org/html/rfc7400#section-3.3) | ||
| */ | ||
| #define GNRC_NETIF2_FLAGS_6LO_BACKBONE (0x00000800U) |
There was a problem hiding this comment.
Shouldn't this be something like GNRC_NETIF2_FLAGS_6LO_GHC?
There was a problem hiding this comment.
No, this has nothing to do with GHC, but with multi-border-router management. Will update the comment above accordingly.
There was a problem hiding this comment.
Okay, I assumed the comment to be correct here.
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| ~GNRC_NETIF2_IPV6_ADDRS_FLAGS_STATE_MASK) | | ||
| GNRC_NETIF2_IPV6_ADDRS_FLAGS_STATE_VALID); | ||
| uint8_t pfx_len = (uint8_t)(opt->context >> 8U); | ||
| /* acquire locks a recursive mutex so we are save calling this |
There was a problem hiding this comment.
Should be "...are safe calling..."
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| break; | ||
| case NETOPT_IPV6_ADDR_REMOVE: | ||
| assert(opt->data_len == sizeof(ipv6_addr_t)); | ||
| /* acquire locks a recursive mutex so we are save calling this |
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| break; | ||
| case NETOPT_IPV6_GROUP: | ||
| assert(opt->data_len == sizeof(ipv6_addr_t)); | ||
| /* acquire locks a recursive mutex so we are save calling this |
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| break; | ||
| case NETOPT_IPV6_GROUP_LEAVE: | ||
| assert(opt->data_len == sizeof(ipv6_addr_t)); | ||
| /* acquire locks a recursive mutex so we are save calling this |
| } | ||
|
|
||
| if (nread < bytes_expected) { | ||
| /* we've got less then the expected packet size, |
|
Thanks for reviewing, @bergzand. I addressed your comments. |
tests/gnrc_netif2/main.c
Outdated
| static inline int _mock_netif_send(gnrc_netif2_t *netif, gnrc_pktsnip_t *pkt); | ||
| static inline gnrc_pktsnip_t *_mock_netif_recv(gnrc_netif2_t * netif); | ||
| static int _get_netdev_address(netdev_t *dev, void *value, size_t max_len); | ||
| static int _set_netdev_address(netdev_t *dev, void *value, size_t value_len); |
There was a problem hiding this comment.
My compiler is complaining hard that value should be of type const void *.
|
Nothing more to add except for my remark above. |
bfa8731 to
173756a
Compare
|
Addressed latest comments and rebased (otherwise the test wouldn't build locally on my machine ;-)) |
| */ | ||
| static inline void gnrc_netif2_acquire(gnrc_netif2_t *netif) | ||
| { | ||
| if (netif && (netif->ops)) { |
There was a problem hiding this comment.
Strange to check for netif->ops here. It's not even used for acquiring a mutex. Good you leave a hint in the doc that netif->ops != NULL is necessary to acquire the mutex?
There was a problem hiding this comment.
netif->ops is NULL before the interface was initialized. If the interface is not initialized it is not necessary to lock its mutex.
| */ | ||
| static inline void gnrc_netif2_release(gnrc_netif2_t *netif) | ||
| { | ||
| if (netif && (netif->ops)) { |
| * @param[in] flags initial flags for the address. | ||
| * - Setting the address' state to | ||
| * @ref GNRC_NETIF2_IPV6_ADDRS_FLAGS_STATE_TENTATIVE | ||
| * means thata this address is assumed to be added due to |
| * - Setting the address' state to | ||
| * @ref GNRC_NETIF2_IPV6_ADDRS_FLAGS_STATE_TENTATIVE | ||
| * means thata this address is assumed to be added due to | ||
| * state-less auto-address configuration and actions |
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| const ipv6_addr_t *dst, | ||
| uint8_t *candidate_set) | ||
| { | ||
| /* create temporary set for assigning "points" to candidates wining in the |
| * | ||
| * @see net_gnrc_netif2_ipv6_addrs_flags | ||
| * | ||
| * @note Only available with module @ref net_gnrc_ipv6 "gnrc_ipv6". |
There was a problem hiding this comment.
Only available with module @ref net_gnrc_ipv6 "gnrc_ipv6".
shouldn't there be a guard around those struct members if they are only available with gnrc_ipv6?
There was a problem hiding this comment.
There is, not just around the single struct members, but around the whole struct ;-).
|
I have no major issues besides those minor – mostly editorial – comments above. I think we can merge here as soon as they are addressed. |
|
Addressed comments |
|
Please squash! |
ae88270 to
77d9770
Compare
|
Squashed and rebased. |
|
Murdock likes it. @cgundogan or @aabadie, can I have an ACK? :) |
|
(3 people - 4 if I count @haukepetersen's inofficial offline review - looked at the code and I addressed all their comments, so I assume the PR is now ACK-worthy ;-)) |
|
@aabadie your comments have been addressed more than a month ago – I will dismiss your change request now to continue with merging (: |
Comments have been addressed by @miri64

This unifies and consolidates the APIs of
gnrc_netdev,gnrc_netif,gnrc_ipv6_netif, andgnrc_sixlowpan_netif.Currently there are only header definitions defined to start some discussion. Basically instead of splitting up the data upon several structs they are unified in one, which is protected by a struct-wise (recursive) mutex. The mutex is necessary, since beside the interface's thread the 6LoWPAN thread and the IPv6 thread will access the struct to save some valuable time otherwise wasted in IPC. GNRC externally the interface is supposed to be accessed viaNETAPI_GETandNETAPI_SET. The requirednetopts still need to be defined in part.TODO:
This PR is part of the network layer remodelling effort:
