Skip to content
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

osal Integration Candidate: 2021-03-23 #917

Merged
merged 49 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cdddcee
Fix #875, Move copyblock size to define
skliper Mar 11, 2021
7cc4e3b
Fix #873, Remove rogue while loop in OS_DeleteAllObjects
skliper Mar 11, 2021
f2fb58c
Fix #859, Consolidate duplicated switch in OS_SocketOpen_Impl
skliper Mar 11, 2021
d414c62
Fix #854, Const correct input pointers
skliper Mar 11, 2021
d1d9e39
Fix #851, Remove duplicate network prototypes
skliper Mar 11, 2021
4750bd2
Fix #842, Remove NULL redefine
skliper Mar 11, 2021
5980693
Fix #868, Use quotes for local includes
skliper Mar 11, 2021
447366f
Fix #855, check against FD_SETSIZE in bsd-select
jphickey Mar 12, 2021
4a21edb
Fix #752, Utilize UTASSERT_CASETYPE_NA to report OS_ERR_NOT_IMPLEMENTED
zanzaben Mar 12, 2021
4d7fc54
Fix #857, correct interval calculation in DoSelect
jphickey Mar 12, 2021
f81f974
Fix #883, remove unreachable test
jphickey Mar 12, 2021
ec15028
Fix #876, break up logic in return statement
jphickey Mar 12, 2021
f1abc0c
Fix #869, rename OS_U32ValueWrapper_t
jphickey Mar 12, 2021
d7c851f
Fix #858, add check for EAGAIN in addition to EINTR
jphickey Mar 12, 2021
7853845
Fix #867, better error translation for ESPIPE errno
jphickey Mar 12, 2021
7a31e37
Fix #882, make module comment same as other services
jphickey Mar 15, 2021
1aad679
Fix #886, return moduleInfoGet error
jphickey Mar 15, 2021
87c9cf2
Fix #861, compile time assert for sockaddr size
jphickey Mar 15, 2021
ef94a3d
Fix #862, comments describing select after connect
jphickey Mar 15, 2021
bb2f5a2
Fix #889, report timer_gettime error
jphickey Mar 15, 2021
e1bfcb1
Fix #911, Add Contributing Guide
arielswalker Mar 16, 2021
ffb3435
Fix #416, add shell functional test
zanzaben Mar 17, 2021
e24723b
Merge pull request #890 from skliper/fix875-copyblock_size
astrogeco Mar 17, 2021
2f128db
Merge pull request #891 from skliper/fix873-rogue_while_loop
astrogeco Mar 17, 2021
04f84f1
Merge pull request #893 from skliper/fix859-switch_logic
astrogeco Mar 17, 2021
c332d9b
Merge pull request #892 from skliper/fix868-include_quotes
astrogeco Mar 17, 2021
8d6638d
Merge pull request #894 from skliper/fix854-const_correct
astrogeco Mar 17, 2021
3546b4e
Merge pull request #895 from skliper/fix851-duplicate_prototype
astrogeco Mar 17, 2021
98b0320
Merge pull request #896 from skliper/fix842-rm_null_redefine
astrogeco Mar 17, 2021
63672f2
Merge pull request #912 from ArielSAdamsNASA/fix-911-add_contributing…
astrogeco Mar 17, 2021
ddd8f27
Merge pull request #914 from zanzaben/fix752_uniform_not_implemented_…
astrogeco Mar 18, 2021
db9b569
Merge pull request #897 from 'jphickey/fix-855-fd-setsize`
astrogeco Mar 19, 2021
58c172c
Merge pull request #898 from `jphickey/fix-857-doselect-calc`
astrogeco Mar 22, 2021
4725184
Merge pull request #909 from jphickey/fix-862-socket-connect-select
astrogeco Mar 22, 2021
c29a2f4
Merge pull request #902 from jphickey/fix-858-check-eagain
astrogeco Mar 22, 2021
a54f95f
Merge pull request #908 from jphickey/fix-861-sockaddr-size-check
astrogeco Mar 22, 2021
e599225
Merge pull request #840 from zanzaben/fix416_shell_functional_test
astrogeco Mar 22, 2021
e9e71c7
Merge pull request #903 from jphickey/fix-867-better-espipe-error
astrogeco Mar 22, 2021
468ab5e
Merge pull request #901 from jphickey/fix-869-rename-value-wrapper
astrogeco Mar 22, 2021
ab66b29
Merge pull request #900 from jphickey/fix-876-breakup-logic
astrogeco Mar 22, 2021
0ad9eb8
Merge pull request #907 from jphickey/fix-889-timer_gettime-err
astrogeco Mar 22, 2021
116677b
Merge pull request #906 from jphickey/fix-886-moduleInfoGet-err
astrogeco Mar 22, 2021
6f02345
Merge pull request #905 from jphickey/fix-882-max-module-comment
astrogeco Mar 22, 2021
0876712
Merge pull request #899 from jphickey/fix-883-mutex-extra-check
astrogeco Mar 22, 2021
cdd57c7
Fix #919, check index inside fdset conversions
jphickey Mar 22, 2021
1583e16
Merge pull request #920 from jphickey/fix-919-fdset-check-id
astrogeco Mar 22, 2021
2b018c0
Fix #921, make non-selectable fd an error
jphickey Mar 22, 2021
db8ccdc
Merge pull request #922 from jphickey/fix-921-non-selectable-fd
astrogeco Mar 22, 2021
65e301e
IC:2021-03-23, Bump to v5.1.0-rc1+dev347
astrogeco Mar 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing Guide

Please see our [top-level contributing guide](https://github.com/nasa/cFS/blob/main/CONTRIBUTING.md) for more information on how to contribute.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History


### Development Build: v5.1.0-rc1+dev347

- Moves copyblock size to a macro and add comments. Defines `OS_CP_BLOCK_SIZE` and adds clear documentation that it could be adjusted for page size, performance, etc.
- Removes while loop
- Replaces all #includes of <os and <OSC_ matches with " to match coding standard.
- Consolidates the duplicated switch in `OS_SocketOpen_Impl`
- Add const to input pointers for `OS_FdSet_ConvertIn_Impl` and `OS_ObjectIdTransactionFinish`
- Removes network prototypes defined in `osapi_sockets.h` that are also in `osapi_network.h`
- Removes `NULL` redefine from `common_types.h`
- Adds `Contributing.md` that points to bundle-level contribution guide
- Reports test cases that "fail" as "not implemented" with new `UtAssert_NA` macro instead of `UtPrintf`
- Calls to `OS_SelectSingle` and `OS_SelectMultiple` will fail if an FD within the set is outside the range of the underlying `FD_SETSIZE` from the C library.
- Fixes calculation used for the relative time interval in the `select()` call. Also adds a UT case that specifically exercises the carryover described. Fixes delay when this carry condition is hit
- Documents algorithm that provides application-controlled timeout on the connection initiation. Also adds a debug statement if the connect fails for a reason other than `EINPROGRESS`. No impact to normal behavior.
- Adds check for `EAGAIN` if the system fails to allocate kernel-internal resources.
- Adds a `CompileTimeAssert` to confirm that the size of the abstract buffer for socket addresses is large enough to store any of the enabled address types thereby removing the need for runtime tests.
- With this change, if `OS_SOCKADDR_MAX_LENis` not large enough for the address type, osal will fail to compile. This enforces that the abstract size is large enough for any/all enabled address types, regardless of what is actually used.
- Adds missing functional test for `OS_ShellOutputToFile`
- Add test for `fcntl()` error return of -1 and report errno. If setting `O_NONBLOCK` fails, then debug message is printed and blocking mode is used and timeouts will not work as a result.
- Improves error codes when attempting to seek on a pipe/socket. Translates the `OS_ERR_OPERATION_NOT_SUPPORTED` error rather than "not implemented". The `ESPIPE` errno means that seeking is not supported on the given file handle.
- Renames `OS_U32ValueWrapper_t` as `OS_VoidPtrValueWrapper_t` to better indicate its purpose. The point is to pass a value through a `void*`. Adds a compile-time assert to check that this is only used to directly pass values which have a size of less than or equal to sizeof(void*).
- Refactors the return statement for `OS_FileSys_FindVirtMountPoint()` so it is easier to read and adds some informational comments.
- Reports an error if calling `timer_gettime` after `timer_settime` fails.
- Returns `OS_ERROR` status to caller after an error on moduleInfoGet()
- Removes an extraneous/unreachable OS_ObjectIdDefined check and its accompanying debug statement. The only way this check could have been reached would be if the normal unlock process was bypassed such that the underlying OS mutex was unlocked but OSAL state still had it owned by a task. This condition never happens at runtime.
- Updates documentation for `OS_MAX_MODULE`
- See <https://github.com/nasa/osal/pull/917>

### Development Build: v5.1.0-rc1+dev297

- Fix #836, Add Testing Tools to the Security Policy
Expand Down
4 changes: 0 additions & 4 deletions src/os/inc/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ extern "C"
*/
typedef void (*OS_ArgCallback_t)(osal_id_t object_id, void *arg);

#ifndef NULL /* pointer to nothing */
#define NULL ((void *)0)
#endif

/*
** Check Sizes
*/
Expand Down
29 changes: 0 additions & 29 deletions src/os/inc/osapi-sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,35 +368,6 @@ int32 OS_SocketGetIdByName(osal_id_t *sock_id, const char *sock_name);
*/
int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Gets the network ID of the local machine
*
* The ID is an implementation-defined value and may not be consistent
* in meaning across different platform types.
*
* @note This API may be removed in a future version of OSAL due to
* inconsistencies between platforms.
*
* @return The ID or fixed value of -1 if the host id could not be found.
* Note it is not possible to differentiate between error codes and valid
* network IDs here. It is assumed, however, that -1 is never a valid ID.
*/
int32 OS_NetworkGetID(void);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Gets the local machine network host name
*
* If configured in the underlying network stack,
* this function retrieves the local hostname of the system.
*
* @param[out] host_name Buffer to hold name information
* @param[in] name_len Maximum length of host name buffer
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_NetworkGetHostName(char *host_name, size_t name_len);
/**@}*/

#endif
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 297
#define OS_BUILD_NUMBER 347
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
70 changes: 42 additions & 28 deletions src/os/portable/os-impl-bsd-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,40 @@
*
* returns: Highest numbered file descriptor in the output fd_set
*-----------------------------------------------------------------*/
static int OS_FdSet_ConvertIn_Impl(fd_set *os_set, OS_FdSet *OSAL_set)
static int32 OS_FdSet_ConvertIn_Impl(int *os_maxfd, fd_set *os_set, const OS_FdSet *OSAL_set)
{
size_t offset;
size_t bit;
osal_index_t id;
uint8 objids;
int osfd;
int maxfd;
int32 status;

maxfd = -1;
status = OS_SUCCESS;
for (offset = 0; offset < sizeof(OSAL_set->object_ids); ++offset)
{
objids = OSAL_set->object_ids[offset];
bit = 0;
while (objids != 0)
{
if (objids & 0x01)
id = OSAL_INDEX_C((offset * 8) + bit);
if ((objids & 0x01) != 0 && id < OS_MAX_NUM_OPEN_FILES)
{
id = OSAL_INDEX_C((offset * 8) + bit);
osfd = OS_impl_filehandle_table[id].fd;
if (osfd >= 0 && OS_impl_filehandle_table[id].selectable)
if (osfd >= 0)
{
FD_SET(osfd, os_set);
if (osfd > maxfd)
if (osfd >= FD_SETSIZE || !OS_impl_filehandle_table[id].selectable)
{
/* out of range of select() implementation */
status = OS_ERR_OPERATION_NOT_SUPPORTED;
}
else
{
maxfd = osfd;
FD_SET(osfd, os_set);
if (osfd > *os_maxfd)
{
*os_maxfd = osfd;
}
}
}
}
Expand All @@ -106,7 +114,7 @@ static int OS_FdSet_ConvertIn_Impl(fd_set *os_set, OS_FdSet *OSAL_set)
}
}

return maxfd;
return status;
} /* end OS_FdSet_ConvertIn_Impl */

/*----------------------------------------------------------------
Expand Down Expand Up @@ -134,9 +142,9 @@ static void OS_FdSet_ConvertOut_Impl(fd_set *output, OS_FdSet *Input)
bit = 0;
while (objids != 0)
{
if (objids & 0x01)
id = OSAL_INDEX_C((offset * 8) + bit);
if ((objids & 0x01) != 0 && id < OS_MAX_NUM_OPEN_FILES)
{
id = OSAL_INDEX_C((offset * 8) + bit);
osfd = OS_impl_filehandle_table[id].fd;
if (osfd < 0 || !FD_ISSET(osfd, output))
{
Expand Down Expand Up @@ -214,12 +222,12 @@ static int32 OS_DoSelect(int maxfd, fd_set *rd_set, fd_set *wr_set, int32 msecs)
if (tv.tv_usec < 0)
{
tv.tv_usec += 1000000;
++tv.tv_sec;
--tv.tv_sec;
}
}

os_status = select(maxfd + 1, rd_set, wr_set, NULL, tvptr);
} while (os_status < 0 && errno == EINTR);
} while (os_status < 0 && (errno == EINTR || errno == EAGAIN));

if (os_status < 0)
{
Expand Down Expand Up @@ -267,6 +275,12 @@ int32 OS_SelectSingle_Impl(const OS_object_token_t *token, uint32 *SelectFlags,
return OS_ERR_OPERATION_NOT_SUPPORTED;
}

if (impl->fd >= FD_SETSIZE)
{
/* out of range of select() implementation */
return OS_ERR_OPERATION_NOT_SUPPORTED;
}

if (*SelectFlags != 0)
{
FD_ZERO(&wr_set);
Expand Down Expand Up @@ -319,41 +333,41 @@ int32 OS_SelectMultiple_Impl(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs)
{
fd_set wr_set;
fd_set rd_set;
int osfd;
int maxfd;
int32 return_code;

/*
* This return code will be used if the set(s) do not
* contain any file handles capable of select(). It
* will be overwritten with the real result of the
* select call, if selectable file handles were specified.
*/
return_code = OS_ERR_OPERATION_NOT_SUPPORTED;
FD_ZERO(&rd_set);
FD_ZERO(&wr_set);
maxfd = -1;
if (ReadSet != NULL)
{
osfd = OS_FdSet_ConvertIn_Impl(&rd_set, ReadSet);
if (osfd > maxfd)
return_code = OS_FdSet_ConvertIn_Impl(&maxfd, &rd_set, ReadSet);
if (return_code != OS_SUCCESS)
{
maxfd = osfd;
return return_code;
}
}
if (WriteSet != NULL)
{
osfd = OS_FdSet_ConvertIn_Impl(&wr_set, WriteSet);
if (osfd > maxfd)
return_code = OS_FdSet_ConvertIn_Impl(&maxfd, &wr_set, WriteSet);
if (return_code != OS_SUCCESS)
{
maxfd = osfd;
return return_code;
}
}

if (maxfd >= 0)
{
return_code = OS_DoSelect(maxfd, &rd_set, &wr_set, msecs);
}
else
{
/*
* This return code will be used if the set(s) were
* both empty/NULL or otherwise did not contain valid filehandles.
*/
return_code = OS_ERR_INVALID_ID;
}

if (return_code == OS_SUCCESS)
{
Expand Down
49 changes: 34 additions & 15 deletions src/os/portable/os-impl-bsd-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ typedef union
#endif
} OS_SockAddr_Accessor_t;

/*
* Confirm that the abstract socket address buffer size (OS_SOCKADDR_MAX_LEN) is
* large enough to store any of the enabled address types. If this is true, the
* size of the above union will match OS_SOCKADDR_MAX_LEN. However, if any
* implemention-provided struct types are larger than this, the union will be
* larger, and this indicates a configuration error.
*/
CompileTimeAssert(sizeof(OS_SockAddr_Accessor_t) == OS_SOCKADDR_MAX_LEN, SockAddrSize);

/****************************************************************************************
Sockets API
***************************************************************************************/
Expand Down Expand Up @@ -102,10 +111,13 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token)
switch (stream->socket_type)
{
case OS_SocketType_DATAGRAM:
os_type = SOCK_DGRAM;
os_type = SOCK_DGRAM;
os_proto = IPPROTO_UDP;
break;

case OS_SocketType_STREAM:
os_type = SOCK_STREAM;
os_type = SOCK_STREAM;
os_proto = IPPROTO_TCP;
break;

default:
Expand All @@ -126,17 +138,6 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token)
return OS_ERR_NOT_IMPLEMENTED;
}

/* Only AF_INET* at this point, can add cases if support is expanded */
switch (stream->socket_type)
{
case OS_SocketType_DATAGRAM:
os_proto = IPPROTO_UDP;
break;
case OS_SocketType_STREAM:
os_proto = IPPROTO_TCP;
break;
}

impl->fd = socket(os_domain, os_type, os_proto);
if (impl->fd < 0)
{
Expand Down Expand Up @@ -200,7 +201,7 @@ int32 OS_SocketBind_Impl(const OS_object_token_t *token, const OS_SockAddr_t *Ad
break;
}

if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN)
if (addrlen == 0)
{
return OS_ERR_BAD_ADDRESS;
}
Expand Down Expand Up @@ -273,10 +274,24 @@ int32 OS_SocketConnect_Impl(const OS_object_token_t *token, const OS_SockAddr_t
{
if (errno != EINPROGRESS)
{
OS_DEBUG("connect: %s\n", strerror(errno));
return_code = OS_ERROR;
}
else
{
/*
* If the socket was created in nonblocking mode (O_NONBLOCK flag) then the connect
* runs in the background and connect() returns EINPROGRESS. In this case we still
* want to provide the "normal" (blocking) semantics to the calling app, such that
* when OS_SocketConnect() returns, the socket is ready for use.
*
* To provide consistent behavior to calling apps, this does a select() to wait
* for the socket to become writable, meaning that the remote side is connected.
*
* An important point here is that the calling app can control the timeout. If the
* normal/blocking connect() was used, the OS/IP stack controls the timeout, and it
* can be quite long.
*/
operation = OS_STREAM_STATE_WRITABLE;
if (impl->selectable)
{
Expand All @@ -290,6 +305,10 @@ int32 OS_SocketConnect_Impl(const OS_object_token_t *token, const OS_SockAddr_t
}
else
{
/*
* The SO_ERROR socket flag should also read back zero.
* If not zero, something went wrong during connect
*/
sockopt = 0;
slen = sizeof(sockopt);
os_status = getsockopt(impl->fd, SOL_SOCKET, SO_ERROR, &sockopt, &slen);
Expand Down Expand Up @@ -560,7 +579,7 @@ int32 OS_SocketAddrInit_Impl(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain)
break;
}

if (addrlen == 0 || addrlen > OS_SOCKADDR_MAX_LEN)
if (addrlen == 0)
{
return OS_ERR_NOT_IMPLEMENTED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/os/portable/os-impl-posix-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int32 OS_GenericSeek_Impl(const OS_object_token_t *token, int32 offset, uint32 w
* Use a different error code to differentiate from an
* error involving a bad whence/offset
*/
retval = OS_ERR_NOT_IMPLEMENTED;
retval = OS_ERR_OPERATION_NOT_SUPPORTED;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/os/posix/inc/os-impl-tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef OS_IMPL_TASKS_H
#define OS_IMPL_TASKS_H

#include <os-shared-task.h>
#include "os-shared-task.h"

#include "osconfig.h"
#include <pthread.h>
Expand Down
2 changes: 1 addition & 1 deletion src/os/posix/inc/os-posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/*
* Use the global definitions from the shared layer
*/
#include <os-shared-globaldefs.h>
#include "os-shared-globaldefs.h"

/****************************************************************************************
DEFINES
Expand Down
Loading