* Determine if a new configuration would represent a valid change * from the current configuration and link activity status. */
| 2565 | * from the current configuration and link activity status. |
| 2566 | */ |
| 2567 | static int |
| 2568 | ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf) |
| 2569 | { |
| 2570 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 2571 | int i, newNumLinksActive; |
| 2572 | |
| 2573 | /* Check per-link config and count how many links would be active */ |
| 2574 | for (newNumLinksActive = i = 0; i < NG_PPP_MAX_LINKS; i++) { |
| 2575 | if (newConf->links[i].enableLink && priv->links[i].hook != NULL) |
| 2576 | newNumLinksActive++; |
| 2577 | if (!newConf->links[i].enableLink) |
| 2578 | continue; |
| 2579 | if (newConf->links[i].mru < MP_MIN_LINK_MRU) |
| 2580 | return (0); |
| 2581 | if (newConf->links[i].bandwidth == 0) |
| 2582 | return (0); |
| 2583 | if (newConf->links[i].bandwidth > NG_PPP_MAX_BANDWIDTH) |
| 2584 | return (0); |
| 2585 | if (newConf->links[i].latency > NG_PPP_MAX_LATENCY) |
| 2586 | return (0); |
| 2587 | } |
| 2588 | |
| 2589 | /* Disallow changes to multi-link configuration while MP is active */ |
| 2590 | if (priv->numActiveLinks > 0 && newNumLinksActive > 0) { |
| 2591 | if (!priv->conf.enableMultilink |
| 2592 | != !newConf->bund.enableMultilink |
| 2593 | || !priv->conf.xmitShortSeq != !newConf->bund.xmitShortSeq |
| 2594 | || !priv->conf.recvShortSeq != !newConf->bund.recvShortSeq) |
| 2595 | return (0); |
| 2596 | } |
| 2597 | |
| 2598 | /* At most one link can be active unless multi-link is enabled */ |
| 2599 | if (!newConf->bund.enableMultilink && newNumLinksActive > 1) |
| 2600 | return (0); |
| 2601 | |
| 2602 | /* Configuration change would be valid */ |
| 2603 | return (1); |
| 2604 | } |
| 2605 | |
| 2606 | /* |
| 2607 | * Free all entries in the fragment queue |