-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gnrc_netif2: Introduction of a new GNRC network interface API #7370
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Briefly went though this one and found some issues with doxygen.
Will see if I can provide an adaption of #7356 in a separate PR.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'It doesn't necessary lock'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What? That doesn't make any sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that negates the the sentence... Lock in is not required, since the thread will do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"It doesn't necessary..." is in any way grammatically wrong ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the missing 'to'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'from via' sounds weird
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gets ?
sys/include/net/gnrc/netif2/conf.h
Outdated
#endif | ||
|
||
/** | ||
* @brief Number of multicast addressed needed for @ref net_gnrc_rpl "RPL". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/addressed/addresses/
const ipv6_addr_t *addr); | ||
|
||
/** | ||
* @brief Get state from address flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gets ? This is no consistent in other places as well.
Addressed @aabadie's comments. |
c40338f
to
943aab0
Compare
Rebased |
f2d599b
to
d53ffd3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind then :)
sys/include/net/gnrc/netif2/flags.h
Outdated
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be something like GNRC_NETIF2_FLAGS_6LO_GHC
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe
} | ||
|
||
if (nread < bytes_expected) { | ||
/* we've got less then the expected packet size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "less than".
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
* @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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thata
* - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state-less => stateless
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wining? :P
* | ||
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ;-)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
@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_GET
andNETAPI_SET
. The requirednetopt
s still need to be defined in part.TODO:
This PR is part of the network layer remodelling effort:
