mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-09 14:14:58 +02:00
pknock: redo inline hints
The compiler is usually smart enough to decide this on its own. Some functions however do not warrant even the hint keyword.
This commit is contained in:
@@ -96,7 +96,7 @@ module_param(nl_multicast_group, int, S_IRUGO);
|
|||||||
* @max
|
* @max
|
||||||
* @return: a 32 bits index
|
* @return: a 32 bits index
|
||||||
*/
|
*/
|
||||||
static uint32_t
|
static inline uint32_t
|
||||||
pknock_hash(const void *key, uint32_t len, uint32_t initval, uint32_t max)
|
pknock_hash(const void *key, uint32_t len, uint32_t initval, uint32_t max)
|
||||||
{
|
{
|
||||||
return jhash(key, len, initval) % max;
|
return jhash(key, len, initval) % max;
|
||||||
@@ -105,8 +105,7 @@ pknock_hash(const void *key, uint32_t len, uint32_t initval, uint32_t max)
|
|||||||
/**
|
/**
|
||||||
* @return: the epoch minute
|
* @return: the epoch minute
|
||||||
*/
|
*/
|
||||||
static unsigned int
|
static inline unsigned int get_epoch_minute(void)
|
||||||
get_epoch_minute(void)
|
|
||||||
{
|
{
|
||||||
struct timespec t = CURRENT_TIME;
|
struct timespec t = CURRENT_TIME;
|
||||||
return t.tv_sec / 60;
|
return t.tv_sec / 60;
|
||||||
@@ -274,8 +273,7 @@ static const struct file_operations pknock_proc_ops = {
|
|||||||
*
|
*
|
||||||
* @rule
|
* @rule
|
||||||
*/
|
*/
|
||||||
static inline void
|
static void update_rule_timer(struct ipt_pknock_rule *rule)
|
||||||
update_rule_timer(struct ipt_pknock_rule *rule)
|
|
||||||
{
|
{
|
||||||
if (timer_pending(&rule->timer))
|
if (timer_pending(&rule->timer))
|
||||||
del_timer(&rule->timer);
|
del_timer(&rule->timer);
|
||||||
@@ -355,8 +353,7 @@ rulecmp(const struct ipt_pknock *info, const struct ipt_pknock_rule *rule)
|
|||||||
* @info
|
* @info
|
||||||
* @return: rule or NULL
|
* @return: rule or NULL
|
||||||
*/
|
*/
|
||||||
static inline struct ipt_pknock_rule *
|
static struct ipt_pknock_rule *search_rule(const struct ipt_pknock *info)
|
||||||
search_rule(const struct ipt_pknock *info)
|
|
||||||
{
|
{
|
||||||
struct ipt_pknock_rule *rule;
|
struct ipt_pknock_rule *rule;
|
||||||
struct list_head *pos, *n;
|
struct list_head *pos, *n;
|
||||||
@@ -502,8 +499,7 @@ remove_rule(struct ipt_pknock *info)
|
|||||||
* @ip
|
* @ip
|
||||||
* @return: peer or NULL
|
* @return: peer or NULL
|
||||||
*/
|
*/
|
||||||
static inline struct peer *
|
static struct peer *get_peer(struct ipt_pknock_rule *rule, uint32_t ip)
|
||||||
get_peer(struct ipt_pknock_rule *rule, uint32_t ip)
|
|
||||||
{
|
{
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct list_head *pos, *n;
|
struct list_head *pos, *n;
|
||||||
@@ -525,8 +521,7 @@ get_peer(struct ipt_pknock_rule *rule, uint32_t ip)
|
|||||||
*
|
*
|
||||||
* @peer
|
* @peer
|
||||||
*/
|
*/
|
||||||
static inline void
|
static void reset_knock_status(struct peer *peer)
|
||||||
reset_knock_status(struct peer *peer)
|
|
||||||
{
|
{
|
||||||
peer->id_port_knocked = 1;
|
peer->id_port_knocked = 1;
|
||||||
peer->status = ST_INIT;
|
peer->status = ST_INIT;
|
||||||
@@ -540,8 +535,7 @@ reset_knock_status(struct peer *peer)
|
|||||||
* @proto
|
* @proto
|
||||||
* @return: peer or NULL
|
* @return: peer or NULL
|
||||||
*/
|
*/
|
||||||
static inline struct peer *
|
static struct peer *new_peer(uint32_t ip, uint8_t proto)
|
||||||
new_peer(uint32_t ip, uint8_t proto)
|
|
||||||
{
|
{
|
||||||
struct peer *peer = kmalloc(sizeof(*peer), GFP_ATOMIC);
|
struct peer *peer = kmalloc(sizeof(*peer), GFP_ATOMIC);
|
||||||
|
|
||||||
@@ -566,8 +560,7 @@ new_peer(uint32_t ip, uint8_t proto)
|
|||||||
* @peer
|
* @peer
|
||||||
* @rule
|
* @rule
|
||||||
*/
|
*/
|
||||||
static inline void
|
static void add_peer(struct peer *peer, struct ipt_pknock_rule *rule)
|
||||||
add_peer(struct peer *peer, struct ipt_pknock_rule *rule)
|
|
||||||
{
|
{
|
||||||
unsigned int hash = pknock_hash(&peer->ip, sizeof(peer->ip),
|
unsigned int hash = pknock_hash(&peer->ip, sizeof(peer->ip),
|
||||||
ipt_pknock_hash_rnd, peer_hashsize);
|
ipt_pknock_hash_rnd, peer_hashsize);
|
||||||
@@ -579,8 +572,7 @@ add_peer(struct peer *peer, struct ipt_pknock_rule *rule)
|
|||||||
*
|
*
|
||||||
* @peer
|
* @peer
|
||||||
*/
|
*/
|
||||||
static inline void
|
static void remove_peer(struct peer *peer)
|
||||||
remove_peer(struct peer *peer)
|
|
||||||
{
|
{
|
||||||
list_del(&peer->head);
|
list_del(&peer->head);
|
||||||
if (peer != NULL)
|
if (peer != NULL)
|
||||||
@@ -886,7 +878,7 @@ update_peer(struct peer *peer, const struct ipt_pknock *info,
|
|||||||
* @payload_len
|
* @payload_len
|
||||||
* @return: 1 if close knock, 0 otherwise
|
* @return: 1 if close knock, 0 otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool
|
static bool
|
||||||
is_close_knock(const struct peer *peer, const struct ipt_pknock *info,
|
is_close_knock(const struct peer *peer, const struct ipt_pknock *info,
|
||||||
const unsigned char *payload, unsigned int payload_len)
|
const unsigned char *payload, unsigned int payload_len)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user