Multiport linux support#303
Conversation
pyhys
left a comment
There was a problem hiding this comment.
Great work!
I think we need to enable filtering of incoming packets dependent on Ethertype already in the Linux kernel, otherwise it will be lots of work for the application. See os_eth_init() in https://github.com/rtlabs-com/p-net/blob/6670292041fd85c028ed1d40c22d5b1ced2fd882/src/osal/linux/osal_eth.c
207a56b to
d904487
Compare
|
Rebased on latest master |
d904487 to
548fd5e
Compare
|
Rebased |
548fd5e to
c9e0ad4
Compare
pyhys
left a comment
There was a problem hiding this comment.
Great!
Mostly trivial changes
c9e0ad4 to
6a56f03
Compare
6a56f03 to
29654d3
Compare
29654d3 to
a0ff3a9
Compare
|
Review comments fixed. |
fredrikdanielmoller
left a comment
There was a problem hiding this comment.
Reviewed changes for Ethernet, LLDP and port handling. Didn't look at code for sample app and unit tests.
a0ff3a9 to
f1e70e3
Compare
|
Review comments fixed |
f1e70e3 to
60262b9
Compare
60262b9 to
65f6a41
Compare
| for test. */ | ||
| char c; | ||
|
|
||
| memset (p_if_list, 0, sizeof (*p_if_list)); |
There was a problem hiding this comment.
Would it be simpler to use strtok(_r)? here instead? Something along the lines of:
char * argv[16];
char * p;
char * saveptr;
/* Split line into argv using space as delimiter */
p = strtok_r (line, " ", &saveptr);
while (p != NULL && argc < NELEMENTS (argv) - 1)
{
argv[argc++] = p;
p = strtok_r (NULL, " ", &saveptr);
}
There was a problem hiding this comment.
Yes, possibly. My first idea was to use strtok, but then I needed to copy arg_str for strtok to be able to insert '\0' and I also need to copy the strings so I ended up with this implementation.
Do you prefer that I use a strtok-based implementation instead?
There was a problem hiding this comment.
When possible we should use the standard libraries. Unfortunately strok is not reentrant and strok_r (which is reentrant) might not be portable (it's not available on windows for instance). So let's stick with this for now.
There was a problem hiding this comment.
This network initialization / configuration from the application is messy. We will try to improvement according to #316. In this case this code may disappear.
| pnal_eth_handle_t * handle; | ||
|
|
||
| handle = (pnal_eth_handle_t *)calloc (1, sizeof (pnal_eth_handle_t)); | ||
| handle = (pnal_eth_handle_t *)calloc (1, 10 /*sizeof (pnal_eth_handle_t)*/); |
There was a problem hiding this comment.
I agree this looks strange. See updated mock implementation.
| return p_buf->len; | ||
| } | ||
|
|
||
| int mock_pnal_eth_recv (void * arg, pnal_buf_t * buf) |
There was a problem hiding this comment.
This seems backwards? The purpose of a mock-function is to decouple from external dependencies. This instead adds an external dependency?
There was a problem hiding this comment.
I have updated the mock implementation.
Done
| p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE); | ||
| memcpy (p_buf->payload, get_name_req, sizeof (get_name_req)); | ||
| ret = pf_eth_recv (net, p_buf); | ||
| ret = mock_pnal_eth_recv (net, p_buf); |
There was a problem hiding this comment.
What is being tested here? Looks like it is a test of the mock-function.
There was a problem hiding this comment.
I have updated the the mock implementation to avoid this.
Done
3a8e838 to
f1de47b
Compare
|
Rebased branch on master |
|
|
||
| handle = (pnal_eth_handle_t *)calloc (1, sizeof (pnal_eth_handle_t)); | ||
|
|
||
| handle->if_name = if_name; |
There was a problem hiding this comment.
Instead of allocating a pnal_eth_handle_t object in this function, perhaps one could initialise mock_os_data.eth_if_handle in mock_init() to some constant pointer, e.g (void*)42, and then return it here?
There was a problem hiding this comment.
Agreed. BTW, doesn't the calloc call leak memory for every test-case using mock_clear()?
There was a problem hiding this comment.
Yes, I assume so. I will update according to Fredriks idea.
1f5358b to
6ce2de1
Compare
| /* Initialize everything (and the DCP protocol) */ | ||
| /* First initialize the network interface */ | ||
| net->eth_handle = | ||
| pnal_eth_init (p_cfg->if_cfg.main_port.if_name, pf_eth_recv, (void *)net); |
There was a problem hiding this comment.
Remove #define pnal_eth_init mock_pnal_eth_init also
There was a problem hiding this comment.
Done, second push below is a rebase on master
6ce2de1 to
fd69be0
Compare
- See doc/multiple_ports.rst for information on how to configure and run a mulitport configuration - Verified on Raspberry Pi with additional USB ethernet interfaces
fd69be0 to
c48c415
Compare
and run a mulitport configuration